Skip to content

Instantly share code, notes, and snippets.

@giovanniramos
Created July 27, 2012 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giovanniramos/3190455 to your computer and use it in GitHub Desktop.
Save giovanniramos/3190455 to your computer and use it in GitHub Desktop.
get_called_class < 5.3 [solution]
<?php
/**
* get_called_class < 5.3 [solution]
*
*/
function get_called_class()
{
$objects = array();
$traces = debug_backtrace();
foreach ($traces as $trace) {
if (isset($trace['object'])) {
if (is_object($trace['object'])) {
$objects[] = $trace['object'];
}
}
}
if (count($objects)) {
return get_class($objects[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment