Re: beginner question about while loops

From: Date: Mon, 09 Feb 2004 15:49:41 +0000
Subject: Re: beginner question about while loops
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-177208@lists.php.net to get a copy of this message
Jochem Maas wrote:
Paul, the warning that John refers to does occur - whether you see it depends on the error reporting level, PHP will create the array for you if you have not already initialized it but a warning will be generated in such cases. ... error_reporting = E_ALL ...
display_errors = On ...
as a rule of thumb it is better to initialize variable before you use them. e.g. $pictures = array(); otherwise, in your case, if no files are present in the directory (or none have a 'jpg' extension) referencing the $pictures array the while loop will cause another error.
Thanks for the advice. I do think the manual is pretty good and I'll spend more time with it. But... I do have error reporting set to all. I think they may have changed the behavior on newer versions of PHP. I have indeed experienced the non-existant array eerror you describe. Lots of debugging to do! PS here's my results from a voracious weekend of coding: <http://hills.ccsf.edu/~pfurma02/index.php?SCREEN=ecards.php> Thanks for all your help!

« previous php.general (#177208) next »