<?php class Foo { protected $var1 = 'a'; protected $var2 = 'b'; public function __toArray() { $result = array(); foreach ($this as $key => $value) { $result[$key] = $value; } return $result; } } $foo = new Foo; $foo->var3 = 'c'; var_dump($foo->__toArray());
You have javascript disabled. You will not be able to edit any code.