note 51353 deleted from language.functions by nikic

From: Date: Wed, 30 Apr 2014 15:27:22 +0000
Subject: note 51353 deleted from language.functions by nikic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-199379@lists.php.net to get a copy of this message
Note Submitter: gilthansNOSPAAM at gmailSPAAMBLOCK dot com ---- Note that a function that calls a variable by reference CANNOT be used recursively, it will generate a CGI error (at least on my windows platform). Thus: <?php $foo = 0; function bar(&$foo){ $foo++; echo $foo."\n"; if($foo < 10) bar($foo); } ?> Will NOT work. Instead, you should just use global variables. <?php $foo = 0; function bar(){ global $foo; $foo++; echo $foo."\n"; if($foo < 10) bar($foo); } ?> This, of course, assuming that you need to use $foo in other functions or parts of code. Otherwise you can simply pass the variable regulary and there should be no problems.

« previous php.notes (#199379) next »