ID:          41487
 Updated by:  [EMAIL PROTECTED]
 Reported By: tayloj1 at uk dot ibm dot com
-Status:      Open
+Status:      Verified
 Bug Type:    Documentation problem
 PHP Version: Irrelevant
-Assigned To: 
+Assigned To: ezyang
 New Comment:

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>



Previous Comments:
------------------------------------------------------------------------

[2007-05-24 13:44:16] tayloj1 at uk dot ibm dot com

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/

------------------------------------------------------------------------

[2007-05-24 10:42:04] 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.




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41487&edit=1

Reply via email to