在我Gazzet類IM面對錯誤,我無法理解,請解釋一下,讓其他對象的屬性到類方法,爲我Gazzet CALSS
注意:試圖讓非對象的屬性在E: \ Web \ xampp \ htdocs \ oop \ includes \ gazett.php on line 71 注意:嘗試獲取第72行中的E:\ Web \ xampp \ htdocs \ oop \ includes \ gazett.php中的非對象的屬性。012,:未定義變量:E:\ Web \ xampp \ htdocs \ oop \ includes \ gazett.php中的courseName在線174 致命錯誤:無法訪問E:\ Web \ xampp \ htdocs \ oop \ includes \ gazett.php中的空屬性在線174
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 =新Gazett($課程);
你可以把你的其他類在這裏也並正確縮進嗎? – jdog