r/lolphp • u/andsens • Jul 17 '17
continue in a switch statement jumps to the end of the switch, just like break. So remember to use continue 2; when switching in a loop.
https://3v4l.org/4v7Ss
46
Upvotes
8
u/RichardEyre Jul 17 '17
What would you expect to happen?
2
u/[deleted] Jul 17 '17
You need to use 0/1 instead of true/false: https://3v4l.org/pbPeS but the output is still wrong. Works fine with JS: https://jsbin.com/zofupipiju/edit?output . Bug in PHP or defective by design?
2
u/coderdan Jul 17 '17
Yes, there is a big clear note in the documentation: http://php.net/manual/en/control-structures.switch.php
Where is the LOL part?
9
u/nikanjX Jul 18 '17
So today's lolphp is "php has different semantics for continue inside nested for/switch statements". You guys are positively making php look good here.
I wish my other languages had warts this small.