PHP oop-1

Source: Internet
Author: User
Tags php oop
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.