PHPã§ç¹ç°ã¡ã½ããï¼ã£ã½ããã®ï¼
PHP5.3ã®ã©ã ããæ®åããã°ããã¨ä½¿ããããã
ã¯ã©ã¹å®ç¾©
<?php class A { function __call($name, $args) { $method = $this->$name; array_unshift($args, $this); // èªåèªèº«ã第ä¸å¼æ°ã¨ãã return call_user_func_array($method, $args); } }
å®è¡
<?php $a = new A(); // ã¡ã½ããå®ç¾©ã第ä¸å¼æ°ã«ã¯ãªãã¸ã§ã¯ãã渡ããã $a->hello = create_function('$self', ' echo "Hello, " . $self->str . "\n"; '); $a->str = 'World'; $a->hello();ã// 'Hello, World'ãåºåããã