在我的Gazzet课程中我遇到了错误,我无法理解,请解释一下,
注意:尝试在第71行的E:\ Web \ xampp \ htdocs \ oop \ includes \ gazett.php中获取非对象的属性 注意:尝试在第72行的E:\ Web \ xampp \ htdocs \ oop \ includes \ gazett.php中获取非对象的属性 注意:未定义的变量:第174行的E:\ Web \ xampp \ htdocs \ oop \ includes \ gazett.php中的courseName 致命错误:无法访问第174行的E:\ Web \ xampp \ htdocs \ oop \ includes \ gazett.php中的空属性
class Gazzet{
private $course, $Regid ;
public $InstName, $Address;
public $courseName, $E_Year;
public $InstName, $Address;
public $courseName, $E_Year;
function __construct($Course, $Regid){
$this->course=$Course;
$this->Regid=$Regid;
$this->madersaName();
$this->course_name();
}
private function madersaName(){
global $obj_madrsa_name;
$obj_madrsa_name = Madaris::madaris_by_id($this->Regid);//here i want to try get public property of obj_madrsa_name , but in vein i m error facing
$this->InstName=$obj_madrsa_name->InstName;// same above error, line 71
$this->Address=$obj_madrsa_name->Address; //same above error, line 72
}
private function course_name(){
global $obj_course;
$obj_course = Courses::courseName($this->course);
$this->$courseName = $obj_course->courseName; // same here, above given error face, line 174
$this->$E_Year = $obj_course->E_Year; // same here, above given error face, line 174
}
}
$ gazett = new Gazett($ Course);
答案 0 :(得分:0)
你的构造需要2个参数:__construct($Course, $Regid )
!!!
在实例创建中只给它一个参数:
$gazett = new Gazett($Course);
注意:你写的是:Ga z
ett,但你的班级名是:Ga zz
et !!!
可能是你的问题!!!试着检查一下!!!
答案 1 :(得分:0)
$ gazette = news Gazette($ Course,$ Regid);
使用此行 我希望你的问题能得到解决 请检查一下...