php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31822 __FUNCTION__ magic constant doesn't work in eval()
Submitted: 2005-02-03 00:35 UTC Modified: 2005-02-03 18:46 UTC
From: clewis at myfonts dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.3 OS: RedHat Enterprise 3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: clewis at myfonts dot com
New email:
PHP Version: OS:

 

 [2005-02-03 00:35 UTC] clewis at myfonts dot com
Description:
------------
The __FUNCTION__ magic constant returns nothing when used in eval()'d code.  __FILE__ and __LINE__ work as expected.

Reproduce code:
---------------
<?php 

function whatFunctionAmI()
{
	eval("print 'the function is: ' . __FUNCTION__;");
}

whatFunctionAmI();

?>

Expected result:
----------------
the function is: whatFunctionAmI

Actual result:
--------------
the function is: 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-03 17:21 UTC] helly@php.net
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

In your example there is no function in your eval\'d code.
 [2005-02-03 18:46 UTC] clewis at myfonts dot com
I see.  I thought the eval() was run in the current 
context, but in fact it runs in its own completely 
separate PHP context?  But that doesn't make sense since 
you can make variable assignments etc within the eval().  
It seems if one can make use of pre-existing variables 
within the eval, it should also know it's inside a 
function.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 21:01:31 2024 UTC