note 45576 added to class.dir

From: Date: Sat, 11 Sep 2004 09:50:13 +0000
Subject: note 45576 added to class.dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-76471@lists.php.net to get a copy of this message
in response to mwb's post about checking for files named zero. he suggested doing <?php // incorrect method while (($file = $d->read()) != "") { .... } ?> do not use his method, it is incorrect. use the method the manual states above, which explicitly checks for false; for some reason the grey box the sample code is in is very narrow and makes it hard to read. for others having this problem here it is, reposted <?php // proper method $d = dir("/etc"); echo "Handle: " . $d->handle . "<br />\n"; echo "Path: " . $d->path . "<br />\n"; while (false !== ($entry = $d->read())) { echo $entry."<br />\n"; } $d->close(); ?> ---- Manual Page -- http://www.php.net/manual/en/class.dir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45576 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45576&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45576&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76471) next »