The member attributes cannot share the class & nbsp; a & nbsp; {& nbsp; public & nbsp; $ a0; & nbsp; & nbsp; public & nbsp; fucntion & nbsp; ax () {& nbsp; & 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 values to an attribute in a method, the other method cannot obtain the value.
PHP
Share to: 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();