|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-05-24 10:42 UTC] tayloj1 at uk dot ibm dot com
Description:
------------
Occurrences of __FUNCTION__ inside an include inside a function declaration do not behave as documented.
The statement:
"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."
is not accurate if the "the code contained in the called file" involves occurrences of __FUNCTION__ .
Additional text should be added :
"An exception to this is the _FUNCTION_ magic constant, which is evaluated before the include occurs."
For more details see http://bugs.php.net/bug.php?id=36370, where this was raised as a functional issue but was closed as bogus.
As the raiser states, at least the documentation should be fixed.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 00:00:01 2025 UTC |
The doc text which needs clarification is in the description of include(), after the first example box (example 16.5) http://uk.php.net/include/I've generalized the issue to note that it applies to all magic constants, not just __FUNCTION__ (although, in practice, people will get confused about __FUNCTION__) Patch: Index: en/language/control-structures.xml =================================================================== RCS file: /repository/phpdoc/en/language/control-structures.xml,v retrieving revision 1.138 diff -u -r1.138 control-structures.xml --- en/language/control-structures.xml 7 May 2007 09:33:54 -0000 1.138 +++ en/language/control-structures.xml 26 May 2007 13:23:26 -0000 @@ -1350,7 +1350,9 @@ 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. So, it will follow - the variable scope of that function. + the variable scope of that function. An exception to this rule is the + magic constant (especially _FUNCTION_), which are evaluated by the + parser before the include occurs. </simpara> <para> <example>