标签:
<?php
class A
{
function foo()
{
if (isset($this)) {
echo ‘$this is defined (‘;
echo get_class($this);
echo ") ";
} else {
echo "$this is not defined. ";
}
}
}
class B
{
function bar()
{
A::foo();
}
}
$a = new A();
$a->foo();
A::foo();
$b = new B();
$b->bar();
B::bar();
?>
以上例程会输出:
$this is defined (a) $this is not defined. $this is defined (b) $this is not defined.
标签:
原文地址:http://www.cnblogs.com/wxdzbc/p/5726446.html