Answer & Solution
The number is: 1
The number is: 2
The number is: 3
because the continue
statement skips the execution of the code block for the value of $i
when it equals 2, and continues with the next iteration.
";
$i++;
if ($i == 2) {
continue;
}
}
?> | PHP | MYTAT">
";
$i++;
if ($i == 2) {
continue;
}
}
?> | PHP | MYTAT">
<?php
$i = 1;
while ($i <= 3) {
echo 'The number is: $i
';
$i++;
if ($i == 2) {
continue;
}
}
?>
The number is: 1
The number is: 2
The number is: 3
because the continue
statement skips the execution of the code block for the value of $i
when it equals 2, and continues with the next iteration.
Which PHP loop is typically used for iterating over the elements of an array?
A). for loop
B). while loop
C). do-while loop
D). foreach loop
Which of the following loops in PHP guarantees that the code block will be executed at least once, even if the condition is false?
A). for loop
B). while loop
C). do-while loop
D). foreach loop
Which control structure in PHP is used to execute a block of code repeatedly as long as a specified condition is true?
A). if statement
B). for loop
C). switch statement
D). while loop
What is the output of the following PHP code?<?php
$x = 1;
while ($x <= 3) {
echo 'The number is: $x
';
$x++;
if ($x == 2) {
break;
}
}
?>
A). The number is: 1
B). The number is: 1
The number is: 2
C). The number is: 2
D). The number is: 1
The number is: 2
The number is: 3
Which PHP control structure is used to execute a block of code repeatedly for a specified number of times?
A). if statement
B). for loop
C). switch statement
D). while loop
Which PHP control structure is used to evaluate multiple conditions and execute a block of code based on the first condition that is true?
A). if-else statement
B). for loop
C). switch statement
D). while loop
Which control structure in PHP is used to execute a block of code if a specified condition is true, and another block of code if the condition is false?
A). if-else statement
B). for loop
C). switch statement
D). while loop
What is the output of the following PHP code?<?php
for ($i = 1; $i <= 3; $i++) {
echo 'The number is: $i
';
}
?>
A). The number is: 1
The number is: 2
The number is: 3
B). The number is: 3
The number is: 2
The number is: 1
C). The number is: 1
D). The number is: 3
Which of the following PHP control structures is used to evaluate an expression against multiple possible cases?
A). if statement
B). for loop
C). switch statement
D). while loop
Which PHP control structure is used to execute a block of code based on the evaluation of a condition?
A). if statement
B). for loop
C). switch statement
D). while loop