Seven syntax descriptions in PHP classes _php tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.