我有以下代碼。爲什麼當我重寫魔術函數時,isset不會返回true __get和__set
我可以知道,爲什麼isset
沒有返回true,當我重寫神奇功能__get
和__set
我得到的輸出是
$param->country : US
isset($param->country) :
<?php
class Param
{
private $params = array();
public function __get($name) {
return $this->params[$name];
}
public function __set($name, $value) {
$this->params[$name] = $value;
}
}
$param = new Param();
$param->country = "US";
echo "\$param->country : " . $param->country . "\n";
echo "isset(\$param->country) : " . isset($param->country) . "\n";