note 21500 added to function.filetype

From: Date: Wed, 15 May 2002 08:39:53 +0000
Subject: note 21500 added to function.filetype
Groups: php.notes 
Request: Send a blank email to php-notes+get-30664@lists.php.net to get a copy of this message
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. -- http://www.php.net/manual/en/function.filetype.php http://master.php.net/manage/user-notes.php?action=edit+21500 http://master.php.net/manage/user-notes.php?action=delete+21500 http://master.php.net/manage/user-notes.php?action=reject+21500

« previous php.notes (#30664) next »