note 27895 deleted from function.is-dir by sniper

From: Date: Mon, 13 Oct 2003 00:35:21 +0000
Subject: note 27895 deleted from function.is-dir by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58450@lists.php.net to get a copy of this message
Note Submitter: tech@appideas.com ---- The comment above (Dec 18, 2002) is not entirely correct. is_file() will also return false if the file does not exist. A better test would be to wrap the is_file() test in a file_exists() test: if( file_exists( $dir ) ) { if( !is_file( $dir ) ) { // this is a directory, do something } } Or a little more compact, but a little less clear way of doing the same thing: if( file_exists( $dir ) && !is_file( $dir ) ) { // this is a directory, do something } The other comment would return that $dir is a directory if the file/dir is not found - probably not what you want in your production code. :-)

« previous php.notes (#58450) next »