Quote:
|
Originally Posted by sde
hey djm, isn't there a slick get/set model for PHP 5 classes?
|
Correct
PHP Code:
<?php
class aphp5class
{
# overloaders don't use the private, protected and public member definition
function __get($key)
{
if (isset($this->$key))
{
return $this->$key;
}
else
{
throw new Exception($key.' does not exist');
}
}
function __set($key, $value)
{
if (isset($this->$key))
{
$this->$key = $value;
mysql_query('UPDATE table SET '.$key.'=\''.$value.'\'');
}
else
{
throw new Exception($key.' does not exist');
}
}
}