The Little Guy Posted May 4, 2011 Share Posted May 4, 2011 Is there a way to do get_called_class for versions lower than php 5.3? Link to comment https://forums.phpfreaks.com/topic/235478-get_called_class-alternative/ Share on other sites More sharing options...
The Little Guy Posted May 4, 2011 Author Share Posted May 4, 2011 I think this works: public function get_called_class(){ if(function_exists('get_called_class')){ return get_called_class(); } $t = debug_backtrace(); $t = $t[0]; if (isset($t['object']) && $t['object'] instanceof $t['class']) return get_class($t['object']); return false; } Link to comment https://forums.phpfreaks.com/topic/235478-get_called_class-alternative/#findComment-1210205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.