- debug_backtrace: documentation ( source)
- print_r: documentation ( source)
<?php
class First {
public function test1() { echo get_called_class(); }
public function test2() { print_r(debug_backtrace()); }
public function test3() { echo get_class($this); }
public function test4() { echo __CLASS__; }
public static function test5() { echo get_called_class(); }
}
function class_alias_kinda($original, $alias) {
eval("class $alias extends $original {}");
}
class_alias_kinda('First', 'Second');
$aliased = new Second();
$aliased->test1(); // Second
$aliased->test2(); // array( 0 => array( ... [object] => Second Object, ... ) )
$aliased->test3(); // Second
$aliased->test4(); // First (this is expected)
Second::test5(); // Second