note 21500 deleted from function.filetype by vincent
| From: | vincent@php.net | Date: | Sat, 16 Aug 2003 21:12:39 +0000 |
| Subject: | note 21500 deleted from function.filetype by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54477@lists.php.net to get a copy of this message | ||
Note Submitter: brendan@tetrinet.cc
----
RE: no.timm@spam.juvik.please.org
>> The way I use to check if a $file is
>> a directory or not, is to see if it
>> has an extension. If a directory
>> name has a "." in it, this
>> wouldn't work, but there are ways
>> to go around that I think. Anyway, this
>> is it:
>>
>> $ext = strrchr($file,'.'); // check for extension
>> if ($ext == "") { // if no extension is found
>> echo $file; // print filename
>> }
Alot more secure and reliable way to do this would be...
if(!is_dir($file) && file_exists($file)) {
echo $file;
}
You wouldn't use is_file() as it wont return true if the file is 0 bytes depending on the
platform.