php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54803 file_exists() error.
Submitted: 2011-05-18 09:36 UTC Modified: 2018-09-30 10:43 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: vinirresko at hotmail dot com Assigned: cmb (profile)
Status: No Feedback Package: *Directory/Filesystem functions
PHP Version: 5.3.6 OS: Windows XP SP3
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vinirresko at hotmail dot com
New email:
PHP Version: OS:

 

 [2011-05-18 09:36 UTC] vinirresko at hotmail dot com
Description:
------------
I found an error on the file_exists() function.
When i try to teste, e.g.:
$dir = "/class/test.php"; // this directory really exists, approved.
When i try to test, returned a false value.

Test script:
---------------
<?
$dir = "/class/test.php"; // this directory really exists, approved.
if(file_exists($dir)){
   print "File ".$dir." exists.";
}else{
   print "File ".$dir." does not exists.";
}
?>

Expected result:
----------------
returns : File /class/test.php exists.

Actual result:
--------------
returns : File /class/test.php does not exists.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-18 09:39 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-05-18 09:39 UTC] pajoye@php.net
What are the permissions of this file? 

Also I'm not sure what it is exactly, you say directory but it seems that you look 
for a file.
 [2011-05-18 10:11 UTC] vinirresko at hotmail dot com
-Status: Feedback +Status: Open
 [2011-05-18 10:11 UTC] vinirresko at hotmail dot com
How can I see the permissions of the file ?

I think this is not blocked.
 [2011-05-18 10:15 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-05-18 10:15 UTC] pajoye@php.net
Also use an absolute path with the drive name if the current drive is not the one 
where this file is (/foo is not an absolute path on windows, c:/foo is).

See the cacls command or the file property to read the perms.
 [2011-05-18 10:20 UTC] vinirresko at hotmail dot com
-Status: Feedback +Status: Open
 [2011-05-18 10:20 UTC] vinirresko at hotmail dot com
Yes, it can be read, and if i test:

require_once("/class/test.php");

it is accepted, so i think who the problem is on the file_exists() function.
 [2011-05-18 10:33 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-05-18 10:33 UTC] pajoye@php.net
No idea what's wrong. Please provide all info I ask and tell us if part of the 
path is a junction or something similar. Is it actually a file? a directory?
 [2011-05-18 10:36 UTC] vinirresko at hotmail dot com
-Status: Feedback +Status: Open
 [2011-05-18 10:36 UTC] vinirresko at hotmail dot com
Right, i'll send the archive, ok ?
<?
$includes = array();
$includes[0] = '/class/conexao.class.php';
$includes[1] = '/class/query.class.php';

for($i = 0; $i < count($includes);$i++){
   try{
	if(file_exists($includes[$i])){
		include_once($includes[$i]);
	}else{
		throw new Exception("Arquivo ".$includes[$i]." não existe.");
	}
	}catch(Exception $e){
			print "<script>alert('".$e->getMessage()."')</script>";
			exit;
		}
}
?>
 [2011-05-18 10:40 UTC] pajoye@php.net
No, thanks.

All I need is the info I asked here. The permission, are junctions part of the 
path, etc.

A simple test case like var_dump("/foo/bar.php"); is enough.
 [2011-05-18 10:42 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-05-18 10:44 UTC] vinirresko at hotmail dot com
-Status: Feedback +Status: Open
 [2011-05-18 10:44 UTC] vinirresko at hotmail dot com
$test = var_dump("/class/autenticacao.class.php");
print $test;

returned: string(29) "/class/autenticacao.class.php"

have no junctions of the pach.
 [2011-05-18 10:48 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-05-18 10:48 UTC] pajoye@php.net
doh.... my mistake but...

ok, let me rephrase:

Please provide:

 - cacls output for this file
 - test using var_dump(file_exists($path));
 - test with an relative path (as in /foo/bar.php not c:/foo/bar.php) and tell 
us how it works
 - test with an absolute path (as in c:/foo/bar.php not /foo/bar.php) and tell 
us how it works

Which SAPI do you use? Apache? FastCgi? Can you try it using the command line 
too?
 [2011-05-18 10:53 UTC] vinirresko at hotmail dot com
-Status: Feedback +Status: Open
 [2011-05-18 10:53 UTC] vinirresko at hotmail dot com
$test = var_dump(file_exists("/class/autenticacao.class.php"));
Returned: bool(false) 

$test = var_dump(file_exists("/class/autenticacao.class.php"));
Returned: bool(true)

I'm using Apache.
 [2011-05-18 10:54 UTC] vinirresko at hotmail dot com
$test = var_dump(file_exists("/class/autenticacao.class.php"));
Returned: bool(false) 

$test = var_dump(file_exists("C:\Arquivos de programas\EasyPHP5.3.0\www\class\autenticacao.class.php"));
Returned: bool(true)

I'm using Apache.

//Sorry, i forget to update pach..
 [2011-05-18 10:56 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-05-18 10:56 UTC] pajoye@php.net
5.3.0? Please try using 5.3.6 or a snapshot.
 [2011-05-18 10:59 UTC] vinirresko at hotmail dot com
-Status: Feedback +Status: Open
 [2011-05-18 10:59 UTC] vinirresko at hotmail dot com
Right, now I'll sleep, but if it dons't work, I back to post here after.
 [2018-09-14 16:52 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-09-14 16:52 UTC] cmb@php.net
> but if it dons't work, I back to post here after.

Since this didn't happen, the issue seams to have been resolved, hasn't it?
 [2018-09-30 10:43 UTC] cmb@php.net
-Status: Feedback +Status: No Feedback
 [2018-09-30 10:43 UTC] cmb@php.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 "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Sep 16 20:03:36 2021 UTC