- property_exists: documentation ( source)
- var_dump: documentation ( source)
<?php
class test {
private $data = array();
public function __get($key) {
echo "get $key\n";
return $this->data[$key];
}
public function __set($key, $value) {
echo "set $key = $value\n";
$this->data[$key] = $value;
}
public function __isset($key) {
return isset($this->data[$key]);
}
}
$test = new test();
var_dump(property_exists($test, 'x'));
var_dump(isset($test->x));
$test->x = 42;
var_dump(property_exists($test, 'x'));
var_dump(isset($test->x));