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? Quote 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; } Quote Link to comment https://forums.phpfreaks.com/topic/235478-get_called_class-alternative/#findComment-1210205 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.