note 31485 added to control-structures.while
| From: | paul at santasoft dot com | Date: | Wed, 23 Apr 2003 19:36:50 +0000 |
| Subject: | note 31485 added to control-structures.while | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46989@lists.php.net to get a copy of this message | ||
PLEASE remember to include your ending } when doing multiple statements inside a while loop. It can
lead to boggling errors like this one:
Parse error: parse error, unexpected $ in /somedir/somefile.php on line 123
where line 123 is the last line in your script.
Caused by the missing } in a piece of code like this:
if (is_dir($upload_directory)) {
if ($dh = opendir($upload_directory)) {
while ($file = readdir($dh)) {
if ($file != "." && $file != "..") {
$files[] = $file;
}
closedir($dh);
}
}
This was burried in a function with several other functions after it and weeding something like that
out is a bugger. Stick with your indentation scheme too. But if you are experiencing weird end of
script errors, then check your while statements!
--
http://www.php.net/manual/en/control-structures.while.php
http://master.php.net/manage/user-notes.php?action=edit+31485
http://master.php.net/manage/user-notes.php?action=delete+31485
http://master.php.net/manage/user-notes.php?action=reject+31485