note 89356 modified in function.get-called-class by danbrown
| From: | danbrown@php.net | Date: | Wed, 04 Mar 2009 15:51:47 +0000 |
| Subject: | note 89356 modified in function.get-called-class by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151463@lists.php.net to get a copy of this message | ||
<?php
if (!function_exists('get_called_class')):
function get_called_class()
{
$bt = debug_backtrace();
if (isset($bt[1]['file']) && isset($bt[1]['line']) &&
isset($bt[1]['function']))
{
$lines = file($bt[1]['file']);
$pattern = '/([a-zA-Z0-9\_]+)::'.$bt[1]['function'].'/';
preg_match($pattern, $lines[$bt[1]['line']-1], $matches);
if (count($matches)>0)
return $matches[0];
}
return false;
}
endif;
?>
--was--
if (!function_exists('get_called_class')):
function get_called_class()
{
$bt = debug_backtrace();
if (isset($bt[1]['file']) && isset($bt[1]['line']) &&
isset($bt[1]['function']))
{
$lines = file($bt[1]['file']);
$pattern = '/([a-zA-Z0-9\_]+)::'.$bt[1]['function'].'/';
preg_match($pattern, $lines[$bt[1]['line']-1], $matches);
if (count($matches)>0)
return $matches[0];
}
return false;
}
endif;
http://php.net/manual/en/function.get-called-class.php