ID:               27891
 User updated by:  faraco dot phpbugs at mailnull dot com
 Reported By:      faraco dot phpbugs at mailnull dot com
 Status:           Open
 Bug Type:         *Directory/Filesystem functions
 Operating System: Windows NT4 SP6
 PHP Version:      5.0.0RC1
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to