__set()
魔法の関数を使用して、php5クラス内にSQLデータを格納したいのですが、関数__get()
内で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のバグでしょうか?