? Php *** this is a person's object * classClassName {public $ name; public $ age; public $ sex; publicstatic $ mystaticvar11; function _ construct ($ name, $ age, $ sex) {here is its own attribute. You can see that $ this already has a $ attribute. It declares that it is an address and can be changed to another attribute.
? Php/*** this is a person's object */class ClassName {public $ name; public $ age; public $ sex; public static $ my = 'static var11 '; function _ construct ($ name, $ age, $ sex) {// this is an attribute of itself. You can see that $ this already exists. The address is declared, it can be re-enabled differently.
Public static $ my = 'static var11'; function _ construct ($ name, $ age, $ sex) {// The attribute is already in use, you can see that $ this already has a $ statement. It declares an address. You can use another address $ this-> name = $ name; $ this-> age = $ age; $ this-> sex = $ sex;} function say () {echo "Hello world ";
Echo self: $ my. "\ n ";
} $ Student = new ClassName ("sun", 20, "male"); echo $ student-> say (); echo"
"; Echo $ student-> name; echo"
"; Echo $ student-> age; echo"
"; Echo $ student-> sex; // The call is similar to the java syntax, that is,". "is changed to"-> "?>
The constructor name is also unified _ construct ();
When new is used, a stack space address is allocated to the object area of the heap space.
Call constructor parent ::__ construct () to compare with super. funName () in java
Self: used to access the attributes and methods of this class to access members or methods within the class.