";
}
?> | PHP | MYTAT"> ";
}
?> | PHP | MYTAT">
Q
What will be the output of the following PHP code?

<?php
for ($i = 1; $i <= 5; $i++) {
if ($i == 3) {
continue;
}
echo 'The number is: $i
';
}
?>

Answer & Solution

Answer: Option B
Solution:
The output of the code will be The number is: 1
The number is: 2
The number is: 4
The number is: 5
because the continue statement skips the execution of the code block for the value of $i when it equals 3, and continues with the next iteration.
Related Questions on Average

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

What will be the output of the following PHP code?

<?php
$x = 5;
do {
echo 'The number is: $x
';
$x++;
} while ($x <= 3);
?>

A). The number is: 5

B). The number is: 5
The number is: 6

C). The number is: 5
The number is: 4

D). The number is: 6

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 PHP control structure is used to execute a block of code multiple times, each time with a different value in a specified range?

A). if statement

B). for loop

C). switch statement

D). while 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 PHP control structure is used to execute a block of code based on the evaluation of multiple conditions?

A). if-else 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

What is the output of the following PHP code?

<?php
$x = 5;
if ($x > 3) {
echo 'Hello';
} else {
echo 'Goodbye';
}
?>

A). Hello

B). Goodbye

C). Nothing

D). Error

Which PHP control structure is used to evaluate a single expression and execute a block of code based on the result of that expression?

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