<?php class father{
function __construct(){
echo"I am a father.<br>";
}
}
class son extends father{
function son1(){
echo"I am a son.<br>";
}
}
$peo=new son();
?>请问输出结果是什么?程序的执行步骤?非常感谢!
function __construct(){
echo"I am a father.<br>";
}
}
class son extends father{
function son1(){
echo"I am a son.<br>";
}
}
$peo=new son();
?>请问输出结果是什么?程序的执行步骤?非常感谢!
<?php
class A{
function test(){
echo "hello!";
}
}
class B extends A{//若A类和B类不在同一文件中 请包含后(include)再操作
function test2(){
parent::test();//子类调用父类方法
echo "test2";
}
}
$a = new B();
$a->test();//hello!
$a->test2();//hello!test2
?>