3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $someVar; private $anotherVar; public function setSomeVar($val) { $this->someVar = $val; } public function getSomeVar() { return $this->someVar; } public function setAnotherVar($val) { $this->anotherVar = $val; } public function getAnotherVar() { return $this->anotherVar; } } $foo = new Foo(); $foo->setSomeVar(12); $foo->setAnotherVar("Hello World"); $fooAsArray = (array) $foo; var_dump($fooAsArray); foreach($fooAsArray as $x) { var_dump($x); }

preferences:
27.19 ms | 404 KiB | 5 Q