Skip to content

Instantly share code, notes, and snippets.

@rmccue
Created July 15, 2012 03:40
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 rmccue/3114816 to your computer and use it in GitHub Desktop.
Save rmccue/3114816 to your computer and use it in GitHub Desktop.
<?php
if (function_exists('get_called_class')) {
$class = get_called_class();
}
else {
$backtrace = debug_backtrace();
$num = count($backtrace);
for ($i = 0; $i < $num; $i++) {
// Ignore the current class, as it's abstract and is never called
if (!empty($backtrace[$i]['class']) && $backtrace[$i]['class'] !== __CLASS__) {
$class = $backtrace[$i]['class'];
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment