< ? php
class Data
{
private $data = array();
public function __set($name, $value)
{
$this->data[$name] = $value;
}
public function __get($name)
{
if (isset($this->data[$name])) { return $this->data[$name]; }
}
public function __isset($name)
{
return isset($this->data[$name]);
}
public function __unset($name)
{
unset($this->data[$name]);
}
}
$data = new Data();
$data->name = ‘F’;
echo “The data value of ‘name’ is {$data->name}”;
unset($data->name);
echo ‘The value is ‘, isset($data->name) ? ” : ‘not ‘, ‘set.’;
? >
class Data
{
private $data = array();
public function __set($name, $value)
{
$this->data[$name] = $value;
}
public function __get($name)
{
if (isset($this->data[$name])) { return $this->data[$name]; }
}
public function __isset($name)
{
return isset($this->data[$name]);
}
public function __unset($name)
{
unset($this->data[$name]);
}
}
$data = new Data();
$data->name = ‘F’;
echo “The data value of ‘name’ is {$data->name}”;
unset($data->name);
echo ‘The value is ‘, isset($data->name) ? ” : ‘not ‘, ‘set.’;
? >
No comments:
Post a Comment
Thank You !