Members of the class:
1. Constant: const constant name = value;
2. Properties
2.1 Static Properties
2.2 Instance Properties
3. Methods
3.1 Static methods
3.2 Example Methods
3.3 Construction methods
3.4 destructor Method
Attention:
① static properties are classes that share this property with objects created by this class
static properties and static methods can be used in ② instance methods
③ static methods can not access instance properties and instance methods, because the static belongs to the class, the instance belongs to the object, class when the object is not new out!
Header"Content-type:text/html;charset=utf-8"); classC{ConstPATH ="C:/windows";//class cannot use define to define constants//static propertiesStatic$count= the;//equivalent to static public $count =;//Instance Properties Public$name="Tom";//equivalent to var $name = "Tom";//Default parameterless constructor//function __construct () {////echo "
__construct is called without a reference to the constructor method;//}//parameter constructor, commonly used for initialization of class member properties, only one constructor can exist for a class in PHP function__construct($name){$this->name =$name;Echo"
The __construct constructor method is called ";}//Instance method functioninstancefun(){Echo"
The instance method is called ";Echo"
Access Constants in Instance methods: ". Self::P Ath;Echo"
Access instance properties in instance method: {$this->name} ";Echo"
To access a static property in an instance method: ". Self::$count;//self represents the class itself .//Call a static method in an instance method Self:: Staticfun ();}//static methodStatic functionstaticfun(){Echo"
The static method is called ";Echo"
Access Constants in Static methods: ". Self::P Ath;Echo"
To access static properties in a static method: ". Self::$count;//Note: Instance properties cannot be accessed in a static method}//destructor, which is called by the system when the object is destroyed//Normally the code is executed and the object is destroyed function__destruct(){Echo"
Object {$this->name} is destroyed ";}}$object=NewC"Harry Potter");$object->instancefun ();Echo""; C::staticfun ();//The following code causes the object that $object points to be destroyed//$object = null;//$object = new C ("Qin Shihuang");//$object = 3;//unset ($object);Echo"
Program last line of code ... ";
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the PHP object-oriented members, including the object-oriented, PHP content, I hope that the PHP tutorial interested in a friend helpful.