- debug_backtrace: documentation ( source)
- function_exists: documentation ( source)
- print_r: documentation ( source)
<?php
class Test
{
public static function className()
{
if (!function_exists('get_called_class')) {
$t = debug_backtrace();
print_r($t);
return;
$t = $t[0];
if (isset($t['object']) && $t['object'] instanceof $t['class'])
return get_class($t['object']);
return false;
return __CLASS__;
}
return get_called_class();
}
}
class Dupa extends Test
{
}
echo Test::className();
echo "\n";
echo Dupa::className();