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.