Using php's magic function inside another function does not work
Posted
by Sirber
on Stack Overflow
See other posts from Stack Overflow
or by Sirber
Published on 2010-04-15T14:00:25Z
Indexed on
2010/04/15
14:03 UTC
Read the original article
Hit count: 309
I want to use magic function __set()
and __get()
for storing SQL data inside a php5 class and I get some strange issue using them inside a function:
Works:
if (!isset($this->sPrimaryKey) || !isset($this->sTable))
return false;
$id = $this->{$this->sPrimaryKey};
if (empty($id))
return false;
echo 'yaay!';
Does not work:
if (!isset($this->sPrimaryKey) || !isset($this->sTable))
return false;
if (empty($this->{$this->sPrimaryKey}))
return false;
echo 'yaay!';
would this be a php bug?
© Stack Overflow or respective owner