Is there a function that can be used to retrieve the name of a statically
called child class from within an inherited method? debug_backtrace() works
for this purpose, but I've seen people say that it is slow. Consider the
example code below. Is this a planned feature for PHP 5, or could this
possibly make it into 4.x? What options do I have?

<?

class a
{
    function test_backtrace()
    {
        $bt = debug_backtrace();
        echo "class pre: ".__CLASS__."\n";
        echo "class bt: ".$bt[0]["class"]."\n";
        echo "class get_class: ".get_class($this)."\n";
    }
}

class b extends a
{
}

echo "** static: \n";
b::test_backtrace();
$b = new b();
echo "** object: \n";
$b->test_backtrace();

?>

Output Looks Like:

** static: 
class pre: a
class bt: b
class get_class: 
** object: 
class pre: a
class bt: b
class get_class: b


Perhaps get_class() could return the expected class name when
called without arguements?


-- 
Phil Dier
gett communications             <http://www.gettcomm.com/>
gettlabs, inc.                  <http://www.gettlabs.com/>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to