0
0
PHPprogramming~5 mins

Continue statement with levels in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the continue statement do in PHP loops?
The continue statement skips the rest of the current loop iteration and moves to the next iteration.
Click to reveal answer
intermediate
What is the purpose of using continue with a numeric argument (levels) in PHP?
Using continue with a number tells PHP to skip the rest of the current iteration of an outer loop that many levels up.
Click to reveal answer
intermediate
How does continue 2; behave inside nested loops?
continue 2; skips the rest of the current iteration of the inner loop and also skips the rest of the current iteration of the outer loop, moving to the next iteration of the outer loop.
Click to reveal answer
beginner
Can continue be used outside of loops in PHP?
No, continue can only be used inside looping structures like for, foreach, while, and do-while loops.
Click to reveal answer
advanced
What happens if you use continue with a level number greater than the number of nested loops?
PHP will generate a warning and treat it as a normal continue (level 1), skipping only the current loop iteration.
Click to reveal answer
What does continue; do inside a loop?
AExits the loop completely
BRestarts the entire program
CSkips the rest of the current iteration and moves to the next iteration
DPauses the loop
What does continue 2; do inside two nested loops?
AExits both loops completely
BSkips the current iteration of the outer loop only
CSkips the current iteration of the inner loop only
DSkips the current iteration of both inner and outer loops
What happens if you use continue 3; inside two nested loops?
APHP ignores the statement
BPHP treats it as <code>continue 1;</code> and skips only the inner loop iteration
CPHP throws a fatal error
DPHP skips three levels of loops
Can continue be used inside a switch statement in PHP?
ANo, <code>continue</code> is for loops only
BNo, it causes a syntax error
CYes, but only with levels
DYes, it skips to the next case
Which of the following is a correct use of continue with levels?
AInside nested loops to skip outer loop iterations
BTo exit a function early
CTo pause execution for a few seconds
DTo restart the entire script
Explain how the continue statement with a numeric level works inside nested loops in PHP.
Think about how many loops you want to skip ahead in.
You got /4 concepts.
    Describe what happens if you use a continue level number greater than the number of nested loops.
    Consider PHP's behavior when the level is too high.
    You got /4 concepts.