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