Usually these methods are useful when you are communicating with a third-party API or when the structure of the method / members is unclear.
Say you are writing a general XML-RPC wrapper. Since you do not know the methods available to you before downloading the WDL file, it makes sense to use Overloading.
Then instead of writing the following:
$xmlrpc->call_method('DoSomething', array($arg1, $arg2));
You can use:
$xmlrpc->DoSomething($arg1, $arg2);
which is more natural syntax.
, .
, : . - , :
class ShortcutDemo {
function &__get($name) {
return call_user_method('get'.$name, $this);
}
function __set($name, &$value) {
return call_user_method('set'.$name, $this, $value);
}
private $_Name;
function &getName() { return $this->_Name; }
function setName(&$value) { $this->_Name = $value; }
}
, - :
$shortcut->Name = 'Hello';