我有以下代码。
我可以知道,为什么当我重写魔术函数并且isset不返回 true 时__get__set
我得到的输出是
$param->country : US
isset($param->country) :
Run Code Online (Sandbox Code Playgroud)
<?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";
Run Code Online (Sandbox Code Playgroud)