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 );