ID: 28775 Comment by: jochem at pepperstream dot nl Reported By: aldo at pepperstream dot nl Status: Open Bug Type: Scripting Engine problem Operating System: SuSe PHP Version: 4.3.6 New Comment:
I updated the script at http://vorm.net/bug28775.tar.gz to use require_once() instead of include(). Problem is the same, and behaviour of include() and require_once() is (and should, according to the manual) be the same in this respect. So I think the quoted part of the manual still applies. So perhaps this behaviour is by design (and not a bug), BUT it is problematic in large projects. It should in my opinion actually behave as C does in this respect, which means the example code should display 'Hello World' instead of 'function not defined'. I would appreciate if others would look at this and test if it is actual a bug and/or behaviour that can be changed. Previous Comments: ------------------------------------------------------------------------ [2004-06-22 15:51:48] aldo at pepperstream dot nl Then the script I put there is wrong. I will upload a new one shortly. It should have set include_once and not include. I will add a new reply with a new script that should simulate the bug. My applogies for the mistake. ------------------------------------------------------------------------ [2004-06-18 19:04:58] imprestavel at gameguru dot com dot br At the url you just said, you gave an example using include, and not include_once/require_once. I suspect that you have the wrong idea of how include works. http://www.php.net/include/ Second paragraph: "Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/ and then in /www/include/." ------------------------------------------------------------------------ [2004-06-16 09:12:30] aldo at pepperstream dot nl Of course. You can find a script that triggers this possible bug at: http://www.vorm.net/bug28775.tar.gz ------------------------------------------------------------------------ [2004-06-14 19:46:57] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try avoid embedding huge scripts into the report. Please provide a complete PHP script needed to reproduce the problem. ------------------------------------------------------------------------ [2004-06-14 17:18:08] aldo at pepperstream dot nl Description: ------------ I hope this bug has not already been reported but I have the following directory structure: root \_ src |_ plugins \_ [nameplugin] \_ src (so a src directory in both root and in a plugin two directories further up) In a file in the root I refer to: require_once('src/library.php'); and I do the same in the root/plugins/[nameplugin] directory: require_once('src/library.php'); Now the second library.php refuses to be included. It referes to two different files, but the include looks similar due to the relative path's being used. When I renamed the second library.php to library2.php a test all my functions and also some test code started working. Reproduce code: --------------- root/index.php require_once('src/library.php'); root/plugins/[nameplugin]/[nameplugin].php require_once('src/library.php'); Expected result: ---------------- I expected both library.php's who exist on different path's to work and not just the one to be included, as both files are actually different, only their names and the relative path to differ. Actual result: -------------- second library.php was not included. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28775&edit=1