__get takes one argument and executes when any inaccessible property of the method is called. It takes name of the property as argument.
__set takes two property and executes when object try to set value in inaccessible property. It take first parameter as name of the property and second as the value which object is try to set.
__call method fires when object of your class is trying to call method of property which is either non accessible or not available. It takes 2 parameter First parameter is string and is name of function. Second parameter is an array which is arguments passed in the function.


<?php
class Hello {
    function __set($name , $value) {
        echo "__set is called on $name for value $value <br/>";
    }
    function __get($name) {
        echo "__get is called on $name <br/>";
    }
}

$obj = new Hello();
$obj->x = 4;
$app = $obj->xyz;
?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: