<?php class Foo { function name_none_static(){ echo "My name is " . get_class() . "<br>"; echo "My name is " . get_class($this) . "<br>"; } } //类内部调用 $bar = new Foo(); $bar->name_none_static(); //类外部调用 echo "Its name is " . get_class($bar) . "<br>"; ?>
输出结果:
My name is Foo
My name is Foo
Its name is Foo