Wednesday, December 9, 2009

Setters and Getters in Access Modifiers

The setter and getter method handlers agrees to read/write the values

class SetterGetterExample{
private $a=1;
public function get_a(){
//log_user_ip_address
return $this->a;
}
public function set_a($value){
$this->a=$value;
}
}

$example=new SetterGetterExample();

//echo $example->a;

echo $example->get_a();
$example->set_a(15);
echo "
";
echo $example->get_a();
?>

Dynamically set and get variable values. This is an abstract class that can be used to dynamically add variables to any class.

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off