Seven syntax descriptions in the PHP class
Seven syntax descriptions in a class
-Properties
-Static properties
-Method
-Static method
-Class constants
-Constructor function
-destructor
'; }//static method public static function Static_stufunction () {echo ' static_function ', '; }//constructor automatically calls public function __construct ($stu _name) {$this->stu_name = $stu _name when creating an object; Echo ' __construct ', '; }//destructors automatically call public function __destruct when destroying objects () {echo ' __destruct ', '; }}//Instantiate class object $object = new Student (' Tom '); Object Invocation Properties Echo $object->stu_name, "; Object call static Property echo $object:: $stu _num, "; Class Call Static property Echo Student:: $stu _num, '; Use objects to invoke methods and static methods $object->stufunction (), respectively; $object->static_stufunction (); $object:: Stufunction (); $object:: Static_stufunction (); Use classes to invoke methods and static methods Student::stufunction (), respectively; Student::static_stufunction (); Class Call class constant echo student::student, ';
Summarize:
objects can call properties and static properties, and classes can only invoke static properties.
objects can call methods and static methods, and classes can call methods and static methods.
http://www.bkjia.com/PHPjc/1012063.html www.bkjia.com true http://www.bkjia.com/PHPjc/1012063.html techarticle The seven syntax descriptions in the PHP class explain the seven syntax descriptions in the class-Properties-static properties-Methods-static methods-class constants-constructors-destructors; static method public static Func ...