在model上,为了获取controller上的变量使用了如下代码:
<code>public function __get($key)
{
return get_instance()->$key;
}
</code>但是在加载view的时候为了获得controller上的变量却选择了把挂在controller上的都挂在了加载器上:
<code>$_ci_CI =& get_instance();
foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var)
{
if ( ! isset($this->$_ci_key))
{
$this->$_ci_key =& $_ci_CI->$_ci_key;
}
}</code>同样的目的为什么选择了不同的方法,我觉得model对应的方法已经非常棒了
在model上,为了获取controller上的变量使用了如下代码:
<code>public function __get($key)
{
return get_instance()->$key;
}
</code>但是在加载view的时候为了获得controller上的变量却选择了把挂在controller上的都挂在了加载器上:
<code>$_ci_CI =& get_instance();
foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var)
{
if ( ! isset($this->$_ci_key))
{
$this->$_ci_key =& $_ci_CI->$_ci_key;
}
}</code>同样的目的为什么选择了不同的方法,我觉得model对应的方法已经非常棒了
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号