PHP learning notes -- [class declaration and Object Instantiation]

Source: Internet
Author: User

Introduction: This is a PHP study note ------ [class declaration and Object Instantiation] Details page, introduced and PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 338286 'rolling = 'no'>

<? PHP/* class declaration * 1. what are you developing and are you sure you want to write? * 2. the members in the class must belong to this class * [modifier class keyword] class name {* member attribute: * member method: *} * 3. when declaring a member attribute in a class, there must be a modifier. When you are not sure which word to use, use VaR or public * To save only one class, and the file name contains the class name, file: Class Name. class. PHP * Class Name: * variable: aaabbbccc * function: aaabbbccc * constant: aaabbbccc * Class Name: aaabbbccc * 4. when multiple objects are created and each object has different attribute values, do not directly give the initial values, after the object is created, the *** class is used to instantiate the object * 1. A new object is created with the class name, which is the object of the created class * $ object reference = new class name; * 2. if a new keyword is used to create an object In the memory, a space is allocated. ** only objects are contained in the bucket. ** the role of objects ** the allocation of objects in the memory ** the use of objects * The members of objects must pass through the object's reference to access * object-> member ** object-> member attribute * object-> member method *** // class declaration (telephone class) class phone {// declare the attribute var $ pinpai; var $ color; var $ batterycapacity; var $ screensize; // member method function call () {} function message () {} function playmusic () {} function photo () {}} // class instantiation class person {var $ name; var $ age; var $ sex; function say () {} function eat () {} function run () {}} // instantiate $ P1 = new person; $ P2 = new person; $ P3 = new person; // Access Object member $ P1-> name = "zhangsan "; echo $ P1-> name;?>

Storage Method of objects in memory

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/338286.html pageno: 9.

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.