Static Variable and Default Argument Initializers Accept Only Scalar Values


Static Variable and Default Argument Initializers Accept Only Scalar Values

That means the values of these initializers must be known at compilation time; that is, they cannot be an expression.

Valid in PHP 3

 <?php $variable = "GLOBALS"; function print_array ($varname = $variable) {     global $$varname;     reset ($$varname);     while (list ($na, $val) = each ($$varname))         print "$na: $val"; } ?> 

Valid in PHP 4

 <?php function print_array ($varname = "GLOBALS") {     global $$varname;     reset ($$varname);     while (list ($na, $val) = each ($$varname))         print "$na, $val\ n<br>\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