PHP中 __call去调用一个成员函数出问题

如此,代码如下
<?php
header("Content-type:text/html;charset=utf-8");
//call

class Monkey{
public $name;
protected $food;

public function __construct($name,$food){
    $this->name = $name;
    $this->food = $food;    
}

public function __call($method,$args){
    return $this->$args[0]($args[1], $args[2]);     
}

//成员函数
public function getSum($n1, $n2){
    return $n1 + $n2;
}

}

$monkey = new Monkey('妖猴','兔子');
$res = $monkey->play('getSum',200,400);
echo $res;
?>

执行后出现

Notice: Array to string conversion in D:\phptools\Apache24\htdocs\oop\call1.php on line 15

Notice: Undefined property: Monkey::$Array in D:\phptools\Apache24\htdocs\oop\call1.php on line 15

Fatal error: Uncaught Error: Function name must be a string in D:\phptools\Apache24\htdocs\oop\call1.php:15 Stack trace: #0 D:\phptools\Apache24\htdocs\oop\call1.php(25): Monkey->__call('play', Array) #1 {main} thrown in D:\phptools\Apache24\htdocs\oop\call1.php on line 15

此处,$args已是一个数组($args[0]=getSum, $args[1]=200,$args[2]=400)
1,为什么出现 Undefined property: Monkey::$Array?
2, $this->$args0;这样调用成员函数为什么会不成功呢?
程序应该是这样执行后求出和才对啊,$this->getSum(200,400);

你的php是什么版本的? 你的写法理应是可以的,php是弱类型语言 你的 Array[0],它可能不认为一定就是字符串类型;避免这样的bug建议可以这样写:
public function __call($method,$args){
$methodName = (string)$args[0] ;
if(empty($methodName))
{
return false;
}else{
return $this->$methodName($args[1], $args[2]);
}
}

第一次在csdn提问。。。。

话说 $字符串(),不是应该试着去解析,并调用一个函数吗?

你定义了一个数组参数但是你传了两个字符串,并且你并没有定义args这个属性但是你却用$this调用了他