PHP Question

If there a way to get the name of the current function? For example,
assume $ErrorList is an object I created to handle all my errors. When an
error takes place, I add the error info to the $ErrorList object, and I
can later use that object for reporting to the user, or to a log file.

<?php

function getSomeData($var1, $var2) { // lines of code // … if ($var1
== “”) { // THIS IS WHERE I WANT THE FUNCTION NAME:
$ErrorList->Add(“Var1 must be specified!”, “<FUNCTION_NAME>
LINE”); } }

?>

Having the function name would be very useful for tracking down bugs.
(we’re talking about a codebase of 200,000 lines)

-Mike K.

On Friday 21 December 2001 11:07 am, Mike King wrote:

>
> If there a way to get the name of the current function? For example,
> assume $ErrorList is an object I created to handle all my errors. When
> an error takes place, I add the error info to the $ErrorList object, and
> I can later use that object for reporting to the user, or to a log file.
>
> <?php
>
> function getSomeData($var1, $var2) { // lines of code // … if ($var1
> == “”) { // THIS IS WHERE I WANT THE FUNCTION NAME:
> $ErrorList->Add(“Var1 must be specified!”, "<FUNCTION_NAME>
> LINE"); } }
>
> ?>

$ErrorList->Add(“Var1 must be specified!”, “<getSomeData> LINE”);

well that’s what I do :slight_smile:


John R. Marshall - Web Developer

JRM Studios - http://www.jrmstudios.com The Hotrodding Network -
http://www.hotrodding.net

Remember: “It ain’t a sport if it can’t kill you.”