The definition of the <?php//class begins with the Class keyword, followed by the name of the classes usually the first letter is capitalized with curly braces to start and end//class properties and methods are preceded by keywords such as public class nbaplayer{ //Define class properties PU Blic $name = "jordan\n"; Public $height = "198cm\n"; Public $weight = "98kg\n"; Public $team = "bull\n"; Public $playernumber = "123\n"; Define method public function jump () { echo "jumping\n"; } Public Function Run () { echo "runing\n"; } Public Function Dribble () { echo "dribble\n"; } Public Function shooting () { echo "shooting\n"; } Public Function Dunk () { echo "dunking\n"; } Public Function Pass () { echo "passing\n"; }};/ /class-to-object instantiation the name of the class () $jordan = new Nbaplayer () followed by the instantiation of the Class ();//The property method in the object can be visited by: instance name, properties Echo $jordan->name. " <br/> "; $jordan->dribble (). " <br/> "; $jordan->run ()." <br/> ";
PHP oop-1