Re: [Linux dev] Undefined variables
| From: | Hendrik Visage | Date: | Fri, 08 Sep 2006 15:21:13 +0000 |
| Subject: | Re: [Linux dev] Undefined variables | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-27135@lists.php.net to get a copy of this message | ||
On 9/8/06, Alf Stockton <alf@stockton.co.za> wrote:
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...
closedir($folder); //sort file names in array sort($names); //remove any non-images from array $tempvar = $i = 0;These "shortcircuit" assignments aren't the best of things to do...
for ($i=0;$names[$i];$i++) { // <----- Line 14
Remember the undefined case up there, there just might not be a
index 0, be rather an index "undefined" ....
Don't we just *love* these interpreted languages and their "funnies" :)
I keep getting:- [Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice: Undefined variable: names in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 8, referer: http://localhost/events/rotate.shtml [Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice: Undefined offset: 13 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 14, referer: http://localhost/events/rotate.shtml Please tell me what evil I have committed to cause this? -- Regards,-- Groete in Jesus Christus, ons enigste Verlosser en Saligmaker Greetings in Jesus Christ, our only Saviour and Salvation. Hendrik VisageAlf Stockton www.stockton.co.zaLay on, MacDuff, and curs'd be him who first cries, "Hold, enough!".-- ShakespeareMy email disclaimer is available at www.stockton.co.za/disclaimer.html --- To unsubscribe: send the line "unsubscribe dev" in the subject of a mail to dev-request@linux.org.za. Problems: dev-admins@linux.org.za Archives at http://www.linux.org.za/Lists-Archives/