06-php object-oriented programming, static method

Source: Internet
Author: User
<? PHP class student {// member variable public static $ member; Public $ name; // constructor public function _ construct ($ name) {$ this-> name = $ name;} // function, which operates static variables. The static function public static function enterschool ($ IFEE) {self :: $ response + = $ IFEE;} // public static function getask() {return self: $ response ;}} // create a student $ stu1 = new student ("Xiaoqian"); // 1. call the static method by class name // Student: enterschool (340); // 2. call the static method $ stu1-> enterschool (340) through an instance; $ fee2 = Student: getf EE (); $ stu2 = new student (""); Student: enterschool (340); $ fee3 = Student: getstudent (); echo "the total tuition fee is :". $ fee3; #1. static methods do not allow static operations as non-state variables. Because the system cannot understand who this actually refers. #2. Operate static variables using static methods. #3. The common member method can operate non-static variables or static variables. ?>

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.