- print_r: documentation ( source)
- get_object_vars: documentation ( source)
<?php
class A
{
private $test1 = 'hello';
protected $test2 = 'world';
public function toArray()
{
$this->test1 = 'sadghsa';
return get_object_vars($this);
}
}
$a = new A();
print_r($a->toArray());