Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo {
- public function getClassname() {
- return get_called_class();
- }
- public function getSelf(){
- return new class extends self { };
- }
- public function getStatic() {
- return new class extends self { };
- }
- }
- class Bar extends Foo {
- }
- $foo = new Foo();
- echo $foo->getClassName(); // Foo
- echo $foo->getSelf()->getClassName(); // Foo::<class>
- echo $foo->getStatic()->getClassName(); // Foo::<class>
- $bar = new Bar();
- echo $bar->getClassName(); // Bar
- echo $bar->getSelf()->getClassName(); // Foo::<class>
- echo $bar->getStatic()->getClassName(); // Bar::<class>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement