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);
|
|
|
|
|
|
|
|
?>
|
2018-02-19 08:59:41 +00:00
|
|
|
--EXPECT--
|
2005-04-23 15:21:07 +00:00
|
|
|
string(5) "Check"
|
|
|
|
string(5) "Check"
|