发布网友
共3个回答
热心网友
header("Content-type: text/html; charset=utf-8");
class person{
public $name;
public $xb;
function _construct($xm,$sex){
$this->name=$xm;
$this->xb=$sex;
}
}
class student extends person{
var $xh;
function _construct($xm,$sex,$id){
$this->xh=$id;
parent::_construct($xm,$sex);
}
function getInfo(){
echo '姓名:'.$this->name.'<br>';
echo '性别:'.$this->xb.'<br>';
echo '学号:'.$this->xh.'<br>';
}
}
$stu1=new student;
$stu1->_construct('张三','男','20011020305');
$stu1->getInfo();
热心网友
麻烦你写代码的时候用半角输入,你这代码的符号全部都是全角符号。
热心网友
construct函数前的两个下划线之间不应该有空格。