|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-02-25 02:57 UTC] sniper@php.net
[2003-02-25 13:49 UTC] alan at frostick dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
Filesystem function: file_exists() return value (PHP_VERSION='4.3.1', PHP_OS='WIN32') file_exists() returns TRUE if it is passed a null string or an undefined variable. e.g. file_exists(""); // returns TRUE Previously it always returned FALSE (at least it did in PHP3). Is that a bug or a change of definition? If so it is undocumented. The rsult is also inconsistent with that returned by is_file() in this case, as my example below demonstrates. I note this is a similar report to apparently "bogus" #19934. Perhaps this will convince you? Example script: As given in Manual\function.file-exists.html (modified to demonstrate the above fault): <?php $filename = ''; print "<BR>file_exists: "; if (file_exists($filename)) { print "The file $filename exists"; } else { print "The file $filename does not exist"; } print "<BR>is_file: "; if (is_file($filename)) { print "The file $filename exists"; } else { print "The file $filename does not exist"; } ?> Result is: file_exists: The file exists is_file: The file does not exist I also tried it with unset($filename) instead of a null string assignment in the above, and get the same result.