Bug #16830 Updated: file_exists("") returns TRUE instead of FALSE
| From: | sniper@php.net | Date: | Sat, 27 Apr 2002 02:11:06 +0000 |
| Subject: | Bug #16830 Updated: file_exists("") returns TRUE instead of FALSE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-6198@lists.php.net to get a copy of this message | ||
ID: 16830
Updated by: sniper@php.net
Reported By: soeren.fleischer@gmx.net
-Status: Open
+Status: Feedback
Bug Type: Filesystem function related
Operating System: Windows 2000 SP2
PHP Version: 4.2.0
New Comment:
Just in case..are you absolutely sure you have updated
all dlls related to PHP in your system? (I assume you had
some older PHP there before)
e.g. php4ts.dll is quite important to be new. Try searching
your filesystem for it. You might have many of them there.
--Jani
Previous Comments:
------------------------------------------------------------------------
[2002-04-26 12:47:20] soeren.fleischer@gmx.net
Sander, please tell me the Bug ID for it.
I did search the Bugs DB for open bugs with "file_exists".
The bug I'm talking about was reported as bug for PHP 4.1.0 ( Bug ID:
15218 ) and it has actually been fixed in 4.1.2, but now it appeared
again in PHP 4.2.0 !!
So this is no duplicate bugreport, I think.
------------------------------------------------------------------------
[2002-04-26 11:59:39] sander@php.net
Plese, SEARCH the bugdb. There is a report about this. (sorry Jani ;)
------------------------------------------------------------------------
[2002-04-25 16:39:58] soeren.fleischer@gmx.net
file_exists("") returns TRUE instead of FALSE
As per request, here are more details...
This:
<?
$filename="";
if (is_file($filename))
{
print "is_file sais, the file $filename <b>does exist</b>.<br>";
}
else
{
print "is_file sais, the file $filename <b>did not exist</b>.<br>";
}
if (file_exists($filename))
{
print "file_exists sais, the file $filename <b>does exist</b>.<br>";
}
else
{
print "file_exists sais, the file $filename <b>did not
exist</b>.<br>";
}
?>
will return:
is_file sais, the file did not exist.
file_exists sais, the file does exist.
Again, in other words:
If you give file_exists() an empty string as argument ( file_exists("")
), it will return TRUE (saying the file existed, but it does not,
because "" is no file.)
is_file() correctly returns FALSE if you give it an empty string as
argument and so should file_exists do, as it did in PHP 4.1.2
Further information:
I used to check my upload-scripts for uploaded files using
$file=$_FILES['datei']['tmp_name'];
if (file_exists($file)) { savefile($file); }
but I cannot use this anymore because when a user does not upload a
file, $filename becomes an empty string and file_exists returns TRUE,
so my function savefile($file) wants to save a non-uploaded file.
------------------------------------------------------------------------
[2002-04-25 16:14:54] tal@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
------------------------------------------------------------------------
[2002-04-25 15:57:50] soeren.fleischer@gmx.net
file_exists("") returns TRUE instead of FALSE.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16830&edit=1