Code: Select all
class foo
{
private $var;
public function __construct()
{
echo (isset($this->var) ? 'yes!' : 'nope');
}
}Is there a function that will give me what I oh so want?
Moderator: General Moderators
Code: Select all
class foo
{
private $var;
public function __construct()
{
echo (isset($this->var) ? 'yes!' : 'nope');
}
}Then how would it be useful in this case...?CoderGoblin wrote:In some instances empty may be of use. Be aware that an empty string or 0 are both counted as empty.
stereofrog wrote:I'm wondering why you would need this (except for debugging).
Code: Select all
if (!property_exists(get_class($this), 'id'))
{
if (!empty($this->_id))
{
$use_id = $this->_id;
}
else
{
trigger_error('Can not save without an id', E_USER_ERROR);
return false;
}
}
else
{
$use_id = 'id';
}Code: Select all
UPDATE table_name SET foo = "bar" WHERE id = "24"Code: Select all
UPDATE table_name SET foo = "bar" WHERE userid = "33"http://php.net/property-exists wrote:Parameters
class
The class name or an object of the class to test for
property
The name of the property