|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-06-02 20:40 UTC] sniper@php.net
[2005-06-10 01:00 UTC] php-bugs at lists dot php dot net
[2005-08-18 10:39 UTC] matthius at pointbtel dot com
[2008-03-29 19:26 UTC] m dot hertzog at mhs dot ch
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
Description: ------------ When I created a lib.inc.php that has a few functions defined (e.g. getmicrocode(), myfunction()) and try to include it on several files with require_once, it somehow included more than once even though the end result of 'path/filename' is identical. My understanding of require_once limitation on Windows (or non-POSIX) platform was that if you have mixed case with the same file name, it will be included again. Another words, as long as you have identical "path/filename" as part of require_once statement, it should include only once. As a result, since you cannot redeclare the same function within the page, you get: Fatal error: Cannot redeclare "functionname()" (previously declared in... Reproduce code: --------------- For example, On lib.inc.php: =============== myfunction1() { echo "hello!";} myfunction2() { echo "hello again!";} On index.php ============ $_my_absolute_path = 'c:/inetpub/wwwroot/'; require_once($_my_absolute_path.'lib.inc.php'); require_once($_my_absolute_path.'template.inc.php'); on template.inc.php =================== $_my_absolute_path = 'c:/inetpub/wwwroot/'; require_once($_my_absolute_path.'lib.inc.php'); // Just in case someone didn't call this previously The realistic code is quite complex: A require_once B and C B require_once C and *D* C require_once *D* and *D* causes redeclare issue when I load A. Expected result: ---------------- the second attempt to include lib.inc.php by using require_once should be ignored because it was already loaded. The same code running on Linux works perfectly and it used to be fine on PHP 4.3.10 But right after I rebuild the server with PHP 5.0.4, I got the following error: Fatal error: Cannot redeclare myfunction1() (previously declared in... Actual result: -------------- the second attempt to include lib.inc.php by using require_once WAS performed and it causes error.