Re: [Linux dev] Undefined variables
| From: | Alex Turner | Date: | Sun, 10 Sep 2006 09:29:00 +0000 |
| Subject: | Re: [Linux dev] Undefined variables | ||
| References: | 1 2 3 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-27140@lists.php.net to get a copy of this message | ||
Alf Stockton wrote:
Hendrik Visage wrote:Anyhow - using variable before they are defined is kind of bad. We try to avoid it. In the above case TPN coding practice would have been to put a line: $names=array(); before the loop. This makes everything very explicit and stable. Cheers AJ -- www.deployview.com www.nerds-central.com www.project-network.comOn 9/8/06, Alf Stockton <alf@stockton.co.za> wrote:Interesting that this works on versions of Windows PHP previous to 5.1.6 Maybe undefined has a meaningful count value in previous versions?In this little script:- <?php session_start(); //read folder $folder=opendir("."); while ($file = readdir($folder)) $names[count($names)] = $file; // <----- Line 8Obviously $names won't be defined in the initial state the first time this line is hit, thus count($names) would/should be undefined...