|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41735 file_exists reports incorrect results
Submitted: 2007-06-19 01:45 UTC Modified: 2007-07-04 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php-bug at okra dot org Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.2.3 OS: Windows Server 2003
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
16 + 22 = ?
Subscribe to this entry?

 [2007-06-19 01:45 UTC] php-bug at okra dot org
file_exists() returns strange results in PHP 5.2.3. This worked fine in 5.2.1. The "Actual result" below is from PHP 5.2.1 on the same server.

Reproduce code:
header('Content-type: text/plain');
foreach (array('d:/home', 'd:/home/', 'd:/home/', 'c:/WINDOWS', 'c:/WINDOWS/system32', 'c:/bogus') as $file) {
  echo "$file: " . (file_exists($file) ? 'yes' : 'no' ) . "\n";

Expected result:
d:/home: yes
d:/home/ yes
d:/home/ yes
c:/WINDOWS: yes
c:/WINDOWS/system32: yes
c:/bogus: no

Actual result:
d:/home: yes
d:/home/ no
d:/home/ yes
c:/WINDOWS: no
c:/WINDOWS/system32: yes
c:/bogus: no


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-19 01:47 UTC] php-bug at okra dot org
Correction: The "Expected result" below is from PHP 5.2.1.
 [2007-06-26 08:01 UTC] php-bug at okra dot org
No change with the snapshot (5.2.4-dev).

FYI, this bug also exists in PHP 4.4.7 and 4.4.6. I'm not sure about earlier versions of PHP 4.

As mentioned in the original bug report, it did NOT exist in PHP 5.2.1.
 [2007-06-26 12:17 UTC]
Not reproducible.
 [2007-06-26 22:55 UTC]
It would be useful to know permissions on all involved directories and also the user under which the test was done.
 [2007-07-04 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-07-22 19:23 UTC] tstarling at wikimedia dot org
This is reproducible by denying the "list folder contents" right for d:\home but allowing it for d:\home\ This surely must be a common setup for shared hosts.
 [2007-07-22 20:05 UTC] tstarling at wikimedia dot org
Here's a batch file for the reproducibly challenged:

mkdir unlistable
mkdir unlistable\subdir
echo Hello > unlistable\subdir\file
echo y| cacls unlistable\subdir /g "%USERNAME%":F
echo y| cacls unlistable /d "%USERNAME%"
php -r "print file_exists('unlistable').\"\n\";"
php -r "print file_exists('unlistable\subdir').\"\n\";"
php -r "print file_exists('unlistable\subdir\file').\"\n\";"

Output is 1, blank, 1.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Apr 12 22:01:23 2021 UTC