a . PHP_EOL; }}class test2 { public function hello(){ $obj = new test1; //var_dump(get_class($obj)); //always abc\test1 $obj->hello(); }}namespace def;class test1 extends \abc\test1 { public $a = ' bbb';}class test2 extends \abc\test2 {}(new test2)->hello();
For advice
How to call Def\test1 instead of abc\test1 in Def\test2 without altering the code of the ABC namespace
Reply content:
a . PHP_EOL; }}class test2 { public function hello(){ $obj = new test1; //var_dump(get_class($obj)); //always abc\test1 $obj->hello(); }}namespace def;class test1 extends \abc\test1 { public $a = ' bbb';}class test2 extends \abc\test2 {}(new test2)->hello();
For advice
How to call Def\test1 instead of abc\test1 in Def\test2 without altering the code of the ABC namespace
The following paragraph changes this:
namespace def;class test1 extends \abc\test1 { public $a = ' bbb';}class test2 extends test1 {}$a= new \def\test2();print_r($a->hello());