#33224 [Opn->Fbk]: require_once includes the same file again even if path/filename is identical
| From: | sniper@php.net | Date: | Thu, 02 Jun 2005 18:40:41 +0000 |
| Subject: | #33224 [Opn->Fbk]: require_once includes the same file again even if path/filename is identical | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79823@lists.php.net to get a copy of this message | ||
ID: 33224
Updated by: sniper@php.net
Reported By: ypae at hotmail dot com
-Status: Open
+Status: Feedback
-Bug Type: Unknown/Other Function
+Bug Type: Scripting Engine problem
Operating System: Windows 2003 Server
PHP Version: 5.0.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-06-02 17:16:47] ypae at hotmail dot com
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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33224&edit=1