php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #9423 Please create a function that returns name of currently executing function
Submitted: 2001-02-23 10:54 UTC Modified: 2002-04-10 18:08 UTC
From: jide at lgb-inc dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS:
Private report: No CVE-ID: None
 [2001-02-23 10:54 UTC] jide at lgb-inc dot com
Please consider adding a new feature to the next version of PHP.

When creating code that reports errors, it would be very helpful
to have a function which returns the name of the currently
executing function (or class method).  You could perhaps
name the function "func_get_name()", which would fit in nicely
with the existing PHP functions "func_get_arg()", "func_get_args()",
and "func_num_args()".  Example usage:

function foo() {
           if ( some error condition ) {
                      ErrorHandler("An error occurrend in function " . func_get_name() );
           }
}

If there is another (existing) way to accomplish this, please let me know.
Thank you for your consideration (and thanks for PHP) -
Jim Ide         jide@lgb-inc.com

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-28 04:15 UTC] sander@php.net
Duplicate of 8576.
 [2002-04-10 18:08 UTC] sniper@php.net
Just added __FUNCTION__ and __CLASS__ constants.
These will be available in PHP 4.3.0.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC