php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48173 file_exists() fails to find in include_path when using __autoload
Submitted: 2009-05-06 23:54 UTC Modified: 2009-05-07 07:58 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kevinpeno at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.9 OS: Windows Server 2008
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: kevinpeno at gmail dot com
New email:
PHP Version: OS:

 

 [2009-05-06 23:54 UTC] kevinpeno at gmail dot com
Description:
------------
Using file_exists fails to find valid files within include_path when using an __autoload. Removing file_exists() the required file is found and loaded.

Safe mode is not enabled.

Reproduce code:
---------------
<?php
function __autoload( $classname )
{
	$file = str_replace( '_', DIRECTORY_SEPARATOR, $classname ).'.php';

	if( file_exists( $file ) )
	{
		require( $file );
		return true;
	}
	else
	{
		return FALSE;
	}
}
# Sets include path to the current directory just for easy testing.
set_include_path( realpath( dirname(__FILE__) ).DIRECTORY_SEPARATOR.PATH_SEPARATOR.get_include_path() );

$test = new Prefix_ClassName();
?>

Expected result:
----------------
File included class initialized.

Actual result:
--------------
Fatal error: Class 'Prefix_ClassName' not found.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-06 23:56 UTC] kevinpeno at gmail dot com
I'm using windows build 5.2.9-2 NTS. This option was not selectable.
 [2009-05-07 07:58 UTC] jani@php.net
file_exists() doesn't care about include_path.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC