note 106993 deleted from function.get-called-class by danbrown

From: Date: Fri, 08 Jun 2012 20:17:46 +0000
Subject: note 106993 deleted from function.get-called-class by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188489@lists.php.net to get a copy of this message
Note Submitter: maxim at inbox dot ru ---- get_called_class i was need to get call function from __costruct and found that php 5.3 returns correct, but no one of there functins neither. So i fix it: <?php if (!function_exists('get_called_class')): function get_called_class() { $bt = debug_backtrace(); $lines = file($bt[1]['file']); preg_match('/([a-zA-Z0-9\_]+)::'.$bt[1]['function'].'/', $lines[$bt[1]['line']-1], $matches); if(empty($matches[1])){ $pp= serialize( $bt[1]["object"]); $nx=strpos($pp,'"')+1; $nx=substr($pp,$nx,strpos($pp,'"')); if (!empty($nx)) { echo " RETURING....: (". $nx . ")<br>"; return $nx; } } echo " RETURING....: (" . $matches[1] . ")<br>"; return $matches[1]; } endif; ?>

« previous php.notes (#188489) next »