1PHPPHPPPHHPPOOPC++Java.netOOPJava.netPHPPHP5OOPPHPerOOPPHP4PHP5PHP5PHP5PHP5OOPPHPPHP5OOPPHPPHPPPHHPPEverythingisObjectEverythingisObjectEEvveerryytthhiinnggiissOObbjjeeccttOOPClass/Object(class)(object)(instance)PHP5PHP5PPHHPP55PHPclass?phpclassPerson{}?PHP2new$p=newPerson();$p=newPerson;PHPPHP5PHPPHP5PPHHPPPPHHPP55/PHP5classpublicprivateprotectedpublicprivateprotected-$this-?phpclassPerson{public$name=NoName;//public$namepublic$age=20;//public$age}$p=newPerson();//echo.$p-name;//$p$nameecho;echo.$p-age;//$age?public?phpclassPerson{public$name=NoName;//$namepublic$age=20;//$age}$p=newPerson();$p-name=Tom;//Tom$p-age=25;//25echo.$p-name;//echo;echo.$p-age;//?PersonPersonPerson3PHP5PHP8booleanintegerfloatdouble”stringarrayobjectresourceNULLPHPPHP5PHPPHP5PPHHPPPPHHPP55/privatepublicgetName()$namegetName()return$this-name$name?phpclassPerson{private$name=NoName;//private$namepublicfunctiongetName(){return$this-name;}}$newperson=newPerson();echo.$newperson-getName();?$this-namegetName()$name,PHP5(private)public45$_a?phpclassPerson{private$a;functionsetA($_a){$thia-a=$_a;}functiongetA(){return$this-a;}}$newperson=newPerson();$newperson-setA(100);echo$newperson-getA();?PHP?phpclassA{public$name=tom;}classPerson{private$a;functionsetA($_a){$this-a=$_a;}functiongetA(){return$this-a;}}$a1=newA();$p=newPerson();5$p-setA($a1);echo$p-getA()-name;?PHP5PHPPHPPPHHPPPHP======,====?phpclassPerson{public$name=NickName;}//$p=newPerson();$p1=newPerson();//if($p==$p1){echo\$p\$p1;}else{echo\$p\$p1;}echo;$p-name=Tom;if($p==$p1){echo\$p\$p1;}else{echo\$p\$p1;}?=====?phpclassPerson{public$name=NickName;6}//$p=newPerson();$p1=newPerson();//if($p===$p1){echo\$p\$p1;}else{echo\$p\$p1;}echo;$p-name=Tom;if($p===$p1){echo\$p\$p1;}else{echo\$p\$p1;}?====?phpclassPerson{public$name=NickName;}$p=newPerson();$p1=newPerson();$p2=$p1;//$p2$p1if($p2===$p1){echo\$p2\$p1;}else{echo\$p2\$p1;}echo;$p=$p1;//$p$p1if($p===$p1){echo\$p\$p1;}else{echo\$p2\$p1;}?PHPPHPPPHHPP7PHP4PHP5?phpclassPerson{private$name;publicfunction__construct($name){$this-name=$name;echo;echo\$nameis$this-name;}}newPerson(tom);newPerson(jack);?PHPPHPPHPPHPPPHHPPPPHHPPGC(GarbageCollector)GC(GarbageCollector)GGCC((GGaarrbbaaggeeCCoolllleeccttoorr))PHPPHPPHPGC(GarbageCollector)PHP__destruct()?phpclassPerson{publicfunction__destruct(){echo;echo;}}$p=newPerson();for($i=0;$i5;$i++){echo$i;}//PHP8?phpclassPerson{publicfunction__destruct(){echo;echo;}}$p=newPerson();$p=null;//for($i=0;$i5;$i++){echo$i;}?$p11$p$pPHPunsetunsetuunnsseett?phpclassPerson{publicfunction__destruct(){echo;}}$p=newPerson();$p1=$p;//$p1unset($p);echo\$p?;for($i=0;$i5;$i++){echo$i;}unset($p1);echo;?unsetunsetPHPPHPPPHHPP9PHPinheritextendsderivePHP5?PhpclassAnimal{private$weight;publicfunctiongetWeight(){return$this-weight;}publicfunctionsetWeight($W){$this-weight=$W;}}classDogextendsAnimal{}?animalDogsetWeight()getWeight()$weight$weight?php……….$myDog=newDog();$myDog-setWeight(20);echoMydog'sweightis.$myDog-getWeight().;$myDog-Bark();?PHP5PHP5Dog1IamanAnimal.”?phpclassAnimal{public$legNum=0;publicfunction__construct(){$this-legNum=4;echoIamananimal;10}}classDog1extendsAnimal{}$dog1=newDog1();echo;echolegNumis.$dog1-legNum;/**/?PHPprivate,PHPprivate,PPHHPPpprriivvaattee,,protected,publicprotected,publicpprrootteecctteedd,,ppuubblliiccPHP5modifierPublic:Private:ProtectedPrivatePrivatePPrriivvaatteeprivateprivate?phpclassMoney{private$mymoney=1000;////publicfunctionloan($num){if($this-mymoney=$num){$this-mymoney=$this-mymoney-$num;echo$num;}else{echo$num;}}}$mon=newMoney();$mon-loan(300);11$mon-loan(600);$mon-loan(400);echo$mon-mymoney;//?ProtectedProtectedPPrrootteecctteeddprotected?phpclassMoney{protected$mymoney=1000;////publicfunctionloan($num){if($this-mymoney=$num){$this-mymoney=$this-mymoney-$num;echo$num;}else{echo$num;}}}classSMoneyextendsMoney{publicfunctiongetMoney(){return$this-mymoney;}}$mon=newSMoney();$mon-loan(900);//echo.$mon-getMoney().;//?PublicPublicPPuubblliiccPublic?phpclassMoney{public$mymoney=1000;////publicfunctionloan($num){if($this-mymoney=$num){$this-mymoney=$this-mymoney-$num;12echo$num;}else{echo$num;}}}$mon=newMoney();$mon-mymoney=$mon-mymoney-5000;echo.$mon-mymoney;echo;?PHPoverridePHPoverridePPHHPPoovveerrrriiddeeoverridePHP5JAVApublicDog”dogDog2Dog?php//classDog{protected$eyeNumber=2;////publicfunctiongetEyeNumber(){return$this-eyeNumber;}//publicfunctionyaff(){returnDogyaff,wang..wang..;}//publicfunctionrun(){returnDogrun..running……;}}$dog=newDog();echodoghave.$dog-getEyeNumber().eyes.;13echo$dog-yaff()..$dog-run();echo;//,classMyDogextendsDog{private$name=;publicfunctiongetName(){return$this-name;}publicfunctionyaff(){return$this-name.yaff,heng……heng..;}}$myDog=newMyDog();echo$myDog-getName().have.$myDog-getEyeNumber().eyes.;echo$myDog-yaff()..$myDog-run();?PHPthisPHPthisPPHHPPtthhiissPHP5$this”$this$this-$this$this,$this?phpclassA{private$a=99;//publicfunctionprintInt($a)