The member attributes cannot share class & nbsp; a & nbsp; {& nbsp; public & nbsp; $ a = 0; & nbsp; public & nbsp; fucntion & nbsp; ax () {& nbsp; member attributes cannot be shared between two methods
class a {
public $a=0;
public fucntion ax(){
$this->a='111';
}
public fucntion bx(){
echo $this->a;
}
}
$ A after assigning a value in ax (), how can I call the $ a value equal to 111 in bx? After assigning a value to an attribute in a method, the other method cannot obtain the value of the PHP class. share the value with: a = '000000 ';?????}???? Pub... 'data-pics = ''>
------ Solution --------------------
After instantiation, execute ax in order, and the bx will have
You need to understand that ax/bx is parallel in the class. it doesn't mean that you write it in front of it, and there are values in the back.
------ Solution --------------------
class a {
public $a=0;
public function a(){
return $this->a='111';
}
public function bx(){
echo $this->a();
}
}
$p = new a();
$p->bx();