|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-24 10:30 UTC] frank at procurios dot nl
[2006-08-30 12:29 UTC] taco at procurios dot nl
[2006-09-05 15:52 UTC] iliaa@php.net
[2006-09-06 06:39 UTC] dmitry@php.net
[2006-09-20 08:06 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 03:00:02 2025 UTC |
Description: ------------ When including a file, require_once() will make a destinction between path/file strings containing forward slashes and backslashes. Reproduce code: --------------- (example) function __autoload($className){ $basePath = 'C:/htdocs'; $classPath= $basePath . '/classes'; require_once($classPath . "/$className.class.php"); } // Some function that doesn't resolves paths function getPath($file){ $path = realpath('./$file'); return $path; } // Autoload $A = new Foo; // Explicit require of class require_once(getPath(Foo.class.php)); $B = new Foo; Expected result: ---------------- One would expect the require_once to notice that Foo has already been loaded and not include the file a second time. Actual result: -------------- Fatal error: Cannot redeclare class foo in c:\htdocs\classes\Foo.class.php on line n (or something like that) Whatever the actual result, the file is loaded twice, as the slashes produced by realpath are distinguished from the slashes used in the defined __autoload() function.