: This article mainly introduces the access and constructor of PHP object-oriented 13 object members. For more information about PHP tutorials, see. 1.1 access to members of an object
Access to member attributes includes assigning values and obtaining member attributes. The members in the access object are similar to the elements in the access array. You can only access each member of an object by referencing the object. $ Reference name = new class name ([parameter quantity list]); // object instantiation format $ reference name-> member attribute = value; // operation for assigning values to member attributes $ echo $ reference name-> member attributes; // obtain the value of member attributes $ reference name-> Member method; // access the member methods in the object
If the members in the object are not static, the "object reference name> attribute" or "object reference name> method" is a unique access form.
1.2 Special object reference "$ this"
Members in the access object must use the reference variable of the object, either outside the object or inside the object. However, after the object is created, the reference name of the object cannot be found in the object method. If you create an object by using the new keyword in the object method, the called member is also a member of the new object. Once an object is created, a special object reference "$ this" exists in each member method of the object ". $ This refers to the object to which the member method belongs. it is used to access members inside the object. Whether it is to use $ this inside the object to access members inside the object, or to access members in the object through the reference name of the object outside the object. All require special operators "->"
ClassPerson {var $ name; var $ sex; var $ age; functionsay () {echo "my name :". $ this-> name. "Gender :". $ this-> sex. "Age ". $ this-> age;} functionrun () {echo $ this-> name. "Walking
";}}
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above section describes the access and constructor of PHP object-oriented 13 objects, including some content, and hope to help those who are interested in PHP tutorials.