class myclass {
var $var1; // this has no default value...
var $var2 = "xyz";
var $var3 = 100;
public $var4; // PHP 5
// constructor
function myclass() {
// change some properties
$this->var1 = "foo";
$this->var2 = "bar";
$this->var4 = '10000000';
return true;
}
}
$my_class = new myclass();
$my_class->myclass();
$reflect = new ReflectionClass($my_class);
$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
list($var1,$var2)=$props;
$class_vars = get_object_vars($my_class);
echo $class_vars[$var1->getName()];
echo $class_vars[$var2->getName()];
exit;
No comments:
Post a Comment