<?php
/* sample code of implementation of Member overloading with help of magic functions
* __set(), __get(), __isset(), __unset()
* author : http://royads.blogspot.com
*/
class test
{
protected $defiened;
protected $data = array();
public function __set($name,$value)
{
echo "\nset data in array";
$this->data[$name] = $value;
}
public function __get($name)
{
echo "\nget from array";
if(array_key_exists($name,$this->data))
return $this->data[$name];
else
return NULL;
}
public function __isset($name)
{
echo "\nchking if set";
return isset($this->data[$name]);
}
public function __unset($name)
{
echo "\nunseting";
unset($this->data[$name]);
}
}
$obj = new test();
echo $obj->notdefiened;
$obj->notdefiened = 'r u there??';
echo $obj->notdefiened;
if(isset($obj->notdefiened))
{
unset($obj->notdefiened);
}
echo $obj->notdefiened;
?>