Skip to content

Instantly share code, notes, and snippets.

@bkudria
Created July 31, 2009 06:53
Show Gist options
  • Save bkudria/159121 to your computer and use it in GitHub Desktop.
Save bkudria/159121 to your computer and use it in GitHub Desktop.
if (!function_exists('get_called_class')) {
function get_called_class() {
$bt = debug_backtrace();
$lines = file($bt[1]['file']);
preg_match(
'/([a-zA-Z0-9\_]+)::'.$bt[1]['function'].'/',
$lines[$bt[1]['line']-1],
$matches
);
return $matches[1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment