|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54422 possibly a bug in file_exists() found
Submitted: 2011-03-30 14:19 UTC Modified: 2013-02-18 00:34 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: f dot roze dot n at hush dot ai Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.3.6 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-03-30 14:19 UTC] f dot roze dot n at hush dot ai
When using built-in function "file_exists" in 5.3.5 I encountered a trouble of locating one file, which had apostrophe in its' name.

$filename = "America's Army.png";
if ( file_exists($filename) ) echo "found it";
else echo "bug";

After backslashing the single quote ("America\'s Army.png"), I managed to get things working.
I considered this as bug since it has nothing o do with DB/HTML backslashing, and also took me a few hours to find out what the problem was.

Test script:
// To test, copy a single file called "America's Army.png" to the initial dir

$filename = "America's Army.png";
if ( file_exists($filename) ) echo "found it";
else echo "bug";

Expected result:
found it

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-06 16:02 UTC]
-Status: Open +Status: Feedback
 [2011-04-06 16:02 UTC]
Can't reproduce this. Are you sure the filename doesn't have a backslash?...

$ ls
file\' 1  file' 2
$ ~/php-t/bin/php
var_dump(file_exists("file\' 1"), file_exists("file' 2"));
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jan 17 23:01:24 2019 UTC