Static methods in php classes cannot inherit the public-modified attributes of other classes. how can this problem be solved?

Source: Internet
Author: User
Static methods in php classes cannot inherit the public-modified attributes of other classes. how can we solve the problem that static methods in php classes cannot inherit the public-modified attributes of other classes? Such as par. class. php and st. class. the php code is as follows: par. class. php code: PHPcodeclasspar {public $ aa; static methods in the publicfunction _ contruct php class cannot inherit the public-modified attributes of other classes. how can this problem be solved?
Static methods in php classes cannot inherit the public-modified attributes of other classes. how can this problem be solved? For example, the code for par. class. php and st. class. php is as follows:

Par. class. php code:
PHP code
  class par{public $aa;public function __contruct(){$this->aa='123456'}}


St. class. php code:
PHP code
  Class st extends par {static function bb {echo $ this-> aa; // this is not accessible. how can this problem be solved }}


------ Solution --------------------
PHP code
Class par {public $ aa; public function _ construct () {$ this-> aa = '000000';} class st extends par {static function bb ($ o) {echo $ o-> aa ;}}$ p = new par; // The same is true for new st: bb ($ p );

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.