go to bug id or search bugs for
file_exists() etc. does not allow checking the existence of files outside the directories specified in open_basedir.
Appearently readfile() does *not* have this restriction and thus allows checking the existence of files anywhere in the filesystem. If realpath($filename) returns a string (i.e. not false), the file exists. This is a circumvention of the open_basedir restriction in file_exists() etc.
The following should always be true, but it isn't when $dir is outside the directories specified in open_basedir:
var_dump(file_exists($dir) === (bool) realpath($dir));
Add a Patch
Add a Pull Request
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.