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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Mon Apr 28 10:01:29 2025 UTC