How can I use a variable in a class to change its value globally in PHP

advertisements

How can I use a variable in a class, such as if I change the value of the variable from member function then its value will be changed globally . How can I do this?


i think you are searching for this:

class abcd {
public $value;
function __construct($value) {
    $this->value        = $value;
}
public function change ($change)
{
     $this->value = $change;
}

}
$new= new abcd (123);
print_r($new);
$new->change (546);
print_r($new);