The basic content of the class in PHP exercises:
<?PHPclasssportobject{ Public $name; Public $height; Public $avirdupois; Public function__construct ($name,$height,$avirdupois) { $this->name =$name; $this->height =$height; $this->avirdupois =$avirdupois; } functionBeatbasketball () {if($this->height >$this->avoirdupois <= 100) { return $this->name. ", meet the requirements of playing basketball. "; } Else { return $this->name. ", not in line with the requirements of playing basketball. "; } } functionshowMe () {Echo' This remark will not be shown. ‘; } function__destruct () {EchoThe <p><b> object is destroyed and the destructor is called. </b></p> "; } } classBeatbasketballextendssportobject{ Public $age; function__construct ($name,$height,$age) { $this->name =$name; $this->height =$height; $this->age =$age; } functionshowMe () {if($this->age > 18) { return $this->name. "To meet the requirements of playing basketball."; } Else { return $this->name. "Not in line with the requirements of playing basketball."; } } } classWeightliftingextendsSportobject {functionshowMe () {if($this->avoirdupois < 85) { return $this->name. ", in line with weightlifting."; } Else { return $this->name. "Not in line with weightlifting."; } } } $sport 1=NewSportobject (' Meteor ', ' 185 ', ' 80 '); Echo $sport 1-Beatbasketball (); Echo"<br>"; $sport 2=NewSportobject (' Sky Fly ', ' 185 ', ' 80 '); Echo $sport 2-Beatbasketball (); Echo"<br>"; $Basketball=NewBeatbasketball (' Tomorrow ', ' 190 ', ' 68 '); $weightlifting=NewWeightlifting (' technology ', ' 185 ', ' 80 ', ' 20 ', ' Male '); Echo"<br>"; Echo $Basketball-showMe (); Echo"<br>"; Echo $weightlifting-showMe (); Echo"<br>"; classbookobject{ConstBoot_type = ' Computer book '; Public $object _name; functionSetobjectname ($name) { $this->object_name =$name; } functionGetobjectname () {return $this-object_name; } } $c _book=NewBookobject (); $c _book->setobjectname ("PHP class"); #echo Bookobject::book_type. " "; Echo $c _book-Getobjectname (); classC {function__call ($name,$num) { Echo"Method Name:".$name." <p></p> "; Echo"The number of parameters exists:".Count($num)." <p></p> "; if(Count($num) = = 1) { Echo $this->list1 ($a); } if(Count($num) = = 2) { Echo $this->list2 ($a,$b); } } Public functionList1 ($a) { return"This is function List1"; } Public functionList2 ($a,$b) { return"This is function List2"; } } Echo"<br>"; $a=NewC; $a->listshow (1, 2); Echo"<br>"; $b=NewC; $b->listshow (1); ?>
Does this even make PHP? -11