Skip to content

Instantly share code, notes, and snippets.

@rmccue
Created Jul 15, 2012
Embed
What would you like to do?
<?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