|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21410 file_exists(), filetype() do not return FALSE for bad filenames: "" or NULL
Submitted: 2003-01-04 13:29 UTC Modified: 2003-02-27 10:42 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: ari at alienhosting dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.2-dev OS: win32 only
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ari at alienhosting dot com
New email:
PHP Version: OS:


 [2003-01-04 13:29 UTC] ari at alienhosting dot com
In the filetype() doc, it says the function returns FALSE on error, but says nothing about a warning being output if it fails. In 4.3.0, A warning is printed:

Warning: filetype() [function.filetype]: Lstat failed for (null) (errno=2 - No such file or directory) in /home/alienhosting/public_html/webmail/plugins/administrator/options.php on line 431


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-04 14:37 UTC]
Changing this bug to a documentation problem.

The warning are now expected for 2 cases: when stat or lstat have failed and when the file type is unknown.

I'm working on fixing the documentation.
 [2003-01-04 14:43 UTC]
The documentation now warns about the warnings :-)

Thank you for your report.
 [2003-01-04 15:12 UTC]
I experience this E_WARNING in linux but in Windows I always get the following with 4.3.0/win2000:

var_dump( filetype(null) ); // string(3) "dir"

Which seems odd.  Basically instead of the E_WARNING error it shows the bogus file as a dir.  This happens with CGI, CLI, and Apache2.

Marking this as a filesystem bug.
 [2003-01-04 15:30 UTC]
To be clearer:  This happens with any bogus information, whether it be a string, NULL, or otherwise.

Of course passing no arguments still results in the standard wrong parameter count error.
 [2003-02-19 23:59 UTC]
Tested with latest CVS snapshot..

 [2003-02-20 00:09 UTC]
Cause of this is that in win32, php_stat() never
tests whether the file exists or not.

 [2003-02-25 02:56 UTC]
Same basic problem with file_exists() too..

 [2003-02-25 02:59 UTC]
Just to clarify:

The base function that is used should check that the 
passed parameter is a) valid b) if valid, the file exists

 [2003-02-27 10:42 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 23:01:31 2024 UTC