【发布时间】:2010-04-15 14:00:25
【问题描述】:
我想使用魔术函数 __set() 和 __get() 在 php5 类中存储 SQL 数据,但在函数中使用它们时遇到了一些奇怪的问题:
作品:
if (!isset($this->sPrimaryKey) || !isset($this->sTable))
return false;
$id = $this->{$this->sPrimaryKey};
if (empty($id))
return false;
echo 'yaay!';
不起作用:
if (!isset($this->sPrimaryKey) || !isset($this->sTable))
return false;
if (empty($this->{$this->sPrimaryKey}))
return false;
echo 'yaay!';
这会是一个 php 错误吗?
【问题讨论】:
标签: php overloading isset