In PHP, how do you get the called aliased class when using class_alias?
问题 I have a class that sets up a class alias for other class names. When a function is called inside of this class via the aliased class, I need to know which alias was used. Is there a way to do this in PHP? I have tried the following code: class foo { public static function test() { var_dump(get_called_class()); } } class_alias('foo', 'bar'); foo::test(); bar::test(); Which outputs: string 'foo' (length=3) string 'foo' (length=3) But I want bar::test(); to output string 'bar' (length=3)