__get() function behavior in php

WiseViz

New Member
I was trying to find the sequence in which magical methods are called in PHP. Hence wrote a very basic program \[code\]class testme{ public $var1; /*function __construct() { echo'<br/> Constructor called'; }*/ public function __set($name, $value) { echo'<br/> You are in sssset function'; } public function __call($method,$arg) { echo '<br/> call method'; } public function __get($name) { echo'<br/> You are in get function'; } public function __isset($name) { echo'<br/> You are in isset function'; } public function __unset($name) { echo'<br/> You are in unset function'; } function __destruct() { print "<br/>Destroying " . $this->name . "\n"; }}$obj = new testme;$obj->var1=5;\[/code\]The expected output was\[code\]You are in set functionDestroying \[/code\]Getting:\[code\]You are in get functionDestroying \[/code\]\[code\]$obj->var1=5\[/code\] Here I am setting the value to the class var then why it is calling \[code\]__get\[/code\]. What is wrong here?
 
Top