#27891 [Fbk->NoF]: Bad behavior of require() function
| From: | sniper@php.net | Date: | Tue, 13 Apr 2004 16:44:30 +0000 |
| Subject: | #27891 [Fbk->NoF]: Bad behavior of require() function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-58043@lists.php.net to get a copy of this message | ||
ID: 27891
Updated by: sniper@php.net
Reported By: faraco dot phpbugs at mailnull dot com
-Status: Feedback
+Status: No Feedback
Bug Type: Zend Engine 2 problem
Operating System: Windows NT4 SP6
PHP Version: 5.0.0RC1
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2004-04-09 12:55:19] sniper@php.net
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
------------------------------------------------------------------------
[2004-04-06 15:21:29] faraco dot phpbugs at mailnull dot com
Here is the confirmation of the bug. Changing index.php to:
<?
echo realpath("../lib/functions.php")."<br>";
echo realpath("lib/functions.php");
?>
Expected result is:
E:\docroot\lib\functions.php
E:\docroot\subroot\lib\functions.php
While actual result is:
E:\docroot\lib\functions.php
E:\docroot\lib\functions.php
------------------------------------------------------------------------
[2004-04-06 15:10:20] faraco dot phpbugs at mailnull dot com
The same script runs perfectly on PHP 4.3.4.
------------------------------------------------------------------------
[2004-04-06 14:55:53] faraco dot phpbugs at mailnull dot com
Sorry. I mistyped the Actual Result. The correct message is:
PHP Fatal error: Cannot redeclare anyfunction() (previously declared
in
E:\docroot\lib\functions.php:4) in E:\docroot\lib\functions.php on
line 7
------------------------------------------------------------------------
[2004-04-06 14:54:18] faraco dot phpbugs at mailnull dot com
Description:
------------
I have the following file structure (folders in uppercase for better
understanding):
DOCROOT
|
+- LIB
| |
| +- functions.php
|
+- SUBROOT
|
+- index.php
|
+- LIB
|
+- functions.php
The 'index.php' file uses the require() function to include both
'functions.php' files (that have different contents). When running
'index.php', a "Cannot redeclare function" error occurs.
Pay attention at the error message: the compiler says that the same
function is redeclared in the same file on different lines!
Reproduce code:
---------------
DOC_ROOT/LIB/functions.php
--------------------------
<?
echo "Here is DOCROOT\\LIB\\functions.php<br>";
function anyfunction($param)
{
return $param;
}
?>
DOCROOT/SUBROOT/LIB/functions.php
---------------------------------
<?
echo "Here is DOCROOT\\SUBROOT\\LIB\\functions.php<br>";
?>
DOC_ROOT/SUBROOT/LIB/index.php
------------------------------
<?
require("../lib/functions.php");
require("lib/functions.php");
echo anyfunction("Hello World!");
?>
Expected result:
----------------
Here is DOCROOT\LIB\functions.php
Here is DOCROOT\SUBROOT\LIB\functions.php
Hello World!
Actual result:
--------------
Here is DOCROOT\LIB\functions.php
PHP Fatal error: Cannot redeclare anyfunction() (previously declared in
C:\doc_root\lib\functions.php:4) in E:\doc_root\lib\functions.php on
line 7
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27891&edit=1