From: alan at frostick dot com
Operating system: WIN32
PHP version: 4.3.1
PHP Bug Type: Filesystem function related
Bug description: file_exists returns TRUE when given a null filename
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.
--
Edit bug report at http://bugs.php.net/?id=22398&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=22398&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=22398&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=22398&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=22398&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=22398&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=22398&r=support
Expected behavior: http://bugs.php.net/fix.php?id=22398&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=22398&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=22398&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=22398&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22398&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=22398&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=22398&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=22398&r=gnused