note 39136 deleted from function.file-exists by nlopess

From: Date: Sun, 18 Jan 2004 15:06:01 +0000
Subject: note 39136 deleted from function.file-exists by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63778@lists.php.net to get a copy of this message
Note Submitter: frank boumphrey ---- file_exists can decieve you sometimes. if you are building a path from a database, say an image path you may have some thing like this $filename="banners/".$arr[0]; where $arr[0] is the file name derived from the database now before displaying the image you want to make sure that it is in fact in the directory thus: if(file_exists($filename)) echo "<img src='$filename' border='0' />" Unfortunately this will display if $arr[0] is empty or null because "banners/" does in fact exist! therefore it is better to use is_file if(is_file($filename)) echo "<img src='$filename' border='0' />"

« previous php.notes (#63778) next »