1.环境搭建
测试环境WampServer2.5继承环境
下载地址:http://rj.baidu.com/soft/detail/10636.html?ald
2.定义父类
class Father{
public function demo1(){
return demo1;
}
public static function demo2(){
return demo2;
}
}
3.定义子类
class son extends Father
{
}
4.访问
echo son::demo1();
//Strict standards: Non-static method Father::demo1() should not be called statically in E:\Develop\wamp\www\test.php on line 24
//Notice: Use of undefined constant demo1 - assumed 'demo1' in E:\Develop\wamp\www\test.php on line 11
echo son::demo2();
//Notice: Use of undefined constant demo2 - assumed 'demo2' in E:\Develop\wamp\www\test.php on line 16
$obj = new Son();
echo $obj -> demo1();
//Notice: Use of undefined constant demo1 - assumed 'demo1' in E:\Develop\wamp\www\test.php on line 11
$obj = new Son();
echo $obj -> demo();
//Notice: Use of undefined constant demo2 - assumed 'demo2' in E:\Develop\wamp\www\test.php on line 16
5.注意
当然注释部分是访问中出现的经过,可以忽略不计,如你需要做处理的话在语句加一个@符号即可