|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-16 02:48 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 02:00:01 2025 UTC |
Description: ------------ When the same file is include_once'd multiple times, but with a different case, PHP does not recognize that actually the same file is included multiple times. This can lead to "cannot redefine function (resp. class)" errors. From looking at the array returned by get_included_files, it seems that PHP handles the list in a case-sensitive way, which obviously is wrong since Win path and file names are not case sensitive. To reproduce the error, create main.php and include.php using the code below. The example produces a "cannot redefine" error, which is unexpected behaviour. When commenting out the function definition and running the example again, one can see that the included file name appears twice in the list, but with different case. Reproduce code: --------------- main.php: print 'main '; include_once ('include.php'); print_r (get_included_files ()); include_once ('Include.php'); print_r (get_included_files ()); include.php: print 'included file '; function included_fn () { print 'included fn '; } Expected result: ---------------- main included file Array ( [0] => main.php [1] => include.php ) included file [full paths removed for clarity] Actual result: -------------- main included file Array ( [0] => main.php [1] => include.php ) included file Fatal error: Cannot redeclare included_fn() (previously declared in include.php:7) in Include.php on line 5 [full paths removed for clarity]