<?php
function get_object_public_vars($object) {
return get_object_vars($object);
}
class Foo {
public $public = 'public';
private $private = 'private';
public function getVars() {
$refl = new ReflectionObject($this);
$props = $refl->getProperties(ReflectionProperty::IS_PUBLIC);
foreach($props as $i => $prop) {
$props[$prop->getName()] = $prop->getValue($this);
unset($props[$i]);
}
return $props;
}
}
$object = new Foo;
$object->runtime = 'value';
print_r($object->getVars());