note 45576 deleted from class.dir by aidan

From: Date: Sat, 11 Sep 2004 11:08:46 +0000
Subject: note 45576 deleted from class.dir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76474@lists.php.net to get a copy of this message
Note Submitter: rehfeld.us ---- 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(); ?>

« previous php.notes (#76474) next »