php-src/tests/classes/__set__get_004.phpt

36 lines
509 B
Plaintext
Raw Normal View History

2005-04-23 15:21:07 +00:00
--TEST--
ZE2 __set() and __get()
--FILE--
<?php
class Test {
2020-02-03 21:52:20 +00:00
protected $x;
2005-04-23 15:21:07 +00:00
2020-02-03 21:52:20 +00:00
function __get($name) {
if (isset($this->x[$name])) {
return $this->x[$name];
}
else
{
return NULL;
}
}
2005-04-23 15:21:07 +00:00
2020-02-03 21:52:20 +00:00
function __set($name, $val) {
$this->x[$name] = $val;
}
2005-04-23 15:21:07 +00:00
}
$foo = new Test();
$bar = new Test();
$bar->baz = "Check";
$foo->bar = $bar;
var_dump($bar->baz);
var_dump($foo->bar->baz);
?>
--EXPECT--
2005-04-23 15:21:07 +00:00
string(5) "Check"
string(5) "Check"