ID: 28775 User updated by: aldo at pepperstream dot nl Reported By: aldo at pepperstream dot nl Status: Bogus Bug Type: Scripting Engine problem Operating System: SuSe PHP Version: 4.3.6 New Comment:
I understand what you mean and it might not be a "bug" but it's really annoying and confusing to work with. Because if I at a lower level in my structure include something there with a name not found in a higher level it WILL work. It only stops working if it can find a match earlier on. So basically your left with 2 "working directories" (not really, but for sake of argument). If you use the same name as found on a top level it will get the one from the top level and if the name can't be found it will also look through the further down level from where the second file with a second include statement is and match files found there. You have to admid it at least is very confusing to work with :) Previous Comments: ------------------------------------------------------------------------ [2004-06-28 11:49:21] [EMAIL PROTECTED] That's not a require_once problem. You are confused about what the current working directory is as your script is executing. All includes are relative to the top script, so even if you include module/module.php and in the include inc/lib.php this will be top/inc/lib.php and not top/module/inc.php. This is so you can move things around and have it work the same no matter where you put things. As long as you keep this in mind and always include relative to the top, everything should work a lot better for you. ;) ------------------------------------------------------------------------ [2004-06-22 17:09:03] jochem at pepperstream dot nl 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. ------------------------------------------------------------------------ [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 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/28775 -- Edit this bug report at http://bugs.php.net/?id=28775&edit=1