The Scopes of break and continue Are Local to That of an Included File, or an eval d String


The Scopes of break and continue Are Local to That of an Included File, or an eval 'd String

Included 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"; } ?> 


PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net