note 35249 deleted from ref.overload by sobak

From: Date: Tue, 22 Nov 2016 03:48:48 +0000
Subject: note 35249 deleted from ref.overload by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207443@lists.php.net to get a copy of this message
Note Submitter: admin (hat) solidox (dawt) org ---- there are a couple of things you should be aware of when using overloading. <? class cTest { function __get($key, &$value) { echo "get: $key<br />"; return true; } function __set($key, $value) { echo "set: $key value: $value<br />"; return true; } function __call($method, $params, &$return) { echo "call: $method params: " . var_export($params, 1) . "<br />"; return true; } } overload('cTest'); $cake = new cTest; ?> firstly it should be noted that nested classes don't work. secondly if you try to set an array it somehow becomes a get and thirdly, if you call a nested class it picks the last nest as the method name, as opposed to a nested get which picks the first in the list. <? $x = $cake->hello->moto; //outputs "get: hello" moto is nowhere to be seen $cake->hello['moto'] = 4; //outputs "get: hello" $cake->moo->cow("hello"); //outputs "call: cow params: array ( 0 => 'hello', )" ?> bit strange, these occur on php4.3.2. havn't tried other versions

« previous php.notes (#207443) next »