php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28445 file_exists incorrect behavior
Submitted: 2004-05-19 14:49 UTC Modified: 2004-07-06 01:44 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: webmaster at freshfm dot com dot au Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.6 OS: FreeBSD 4.7-RELEASE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: webmaster at freshfm dot com dot au
New email:
PHP Version: OS:

 

 [2004-05-19 14:49 UTC] webmaster at freshfm dot com dot au
Description:
------------
PHP4.3.6RC3 Actually. Previously reported for different versions; #21410, #16830

Will *at seemingly random* times produce incorrect behavior.

IE:
"./images/members/admin.jpg" does not exist, but for some reason it returns true.

Apologies if this has been corrected in later versions, I can't tell - my ISP is evil.

Reproduce code:
---------------
function pictureExists($path, $extensions) {

    for ($i=0;$i<=count($extensions);$i++) {
		print $path . "." . $extensions[$i];
		phpinfo();
		print file_exists($path . "." . $extensions[$i]);
		print true;
        if (file_exists($path . "." . $extensions[$i]) == true) {
            return "." . $extensions[$i];
        }
    }

    return false;
}

$path = "./images/members/admin";
$exts[] = "jpg";
pictureExists($path,$exts);

Expected result:
----------------
return true


Actual result:
--------------
return false.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-06 01:44 UTC] sniper@php.net
See the manual page for file_exists() and the note about 'cached'..

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 23:01:33 2025 UTC