ID: 36370 User updated by: rbro at hotmail dot com Reported By: rbro at hotmail dot com Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 5.1.2 New Comment:
Thanks for the explanation. I'm thinking that maybe the documentation for include() should be updated since right now it states "all of the code contained in the called file will behave as though it had been defined inside that function" which is not true if you use __FUNCTION__ inside your included file which is the exact issue I ran into in my code. Previous Comments: ------------------------------------------------------------------------ [2006-02-12 21:32:04] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php __FUNCTION__ is something handled by the parser, and not the executor. This means that it has no knowlegde where it was included from and as the __FUNCTION__ appears outside of a function declaration it ofcourse returns NULL. ------------------------------------------------------------------------ [2006-02-12 16:51:06] rbro at hotmail dot com Thanks for the update, but why is this not a bug? I did look at the documentation before submitting this bug and http://us3.php.net/include states the following: "If the include occurs inside a function within the calling file, then all of the code contained in the called file will behave as though it had been defined inside that function." which then contradicts the Actual Result that I'm getting because if I move my included code into the main file, then the output is different: 1. Function is: test 2. Function is: test ------------------------------------------------------------------------ [2006-02-12 14:22:08] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . ------------------------------------------------------------------------ [2006-02-12 04:03:10] rbro at hotmail dot com Description: ------------ If you include a file within a function, the constant __FUNCTION__ is not available from that include file. Reproduce code: --------------- <?php function test() { echo "1. Function is: ".__FUNCTION__."\n"; require('b.php'); } test(); ?> ------- File b.php contains: <?php echo "2. Function is: ".__FUNCTION__."\n"; ?> Expected result: ---------------- 1. Function is: test 2. Function is: test Actual result: -------------- 1. Function is: test 2. Function is: ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36370&edit=1
