The Scopes of break and continue Are Local to That of an Included File, or an eval 'd StringIncluded files and eval 'd strings now have a different scope than the main code. Therefore, the break and continue statements will not affect the main code. Valid in PHP 3<?php $names = array ("Jackie", "Greg", "Grant", "Julie", "Peter"); while (list (, $name) = each ($names)) { eval('if (!strcmp ($name, "Grant")) break;'); print "$name\n"; } ?> Valid in PHP 4<?php $names = array("Jackie", "Greg", "Grant", "Julie", "Peter"); while (list (, $name) = each ($names)) { $should_break = eval ('if (!strcmp ($name, "Grant")) return 0; else return 1;'); if ($should_break) break; print "$name\n"; } ?> |