From:             faraco dot phpbugs at mailnull dot com
Operating system: Windows NT4 SP6
PHP version:      5.0.0RC1
PHP Bug Type:     *Directory/Filesystem functions
Bug description:  Bad behavior of require() function

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 bug report at http://bugs.php.net/?id=27891&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27891&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27891&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27891&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27891&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27891&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27891&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27891&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27891&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27891&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27891&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27891&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27891&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27891&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27891&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27891&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27891&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27891&r=float

Reply via email to