<?php
class C {
function fo(){
if (isset($this))
echo "this is a difined calss(".get_class($this).")";
else echo "this is not a defined class";
}
}
class D{
function bar(){
C::fo();
//在没有声明任何实例的情况下访问类中的函数或者基类中的函数和变量很有用处。而 :: 运算符即用于此情况。
}
}
$c=new C;
$c->fo(); //输出结果:this is a difined calss(C)
C::fo(); //输出结果:this is not a defined class
$d=new D;
$d->bar(); //输出结果:this is a difined calss(D)
D::bar(); //输出结果:this is not a defined class
?>