对php魔术方法的误解

对php魔术方法的误解,php,oop,Php,Oop,结果是:调用方法blabla,参数计数为:1 问题:为什么参数计数是1而不是3?我错在哪里?脚本不计算数组中的项目,只计算参数号,唯一的参数是$arr 您需要使用以下方法计算项目: class My_class { public function __call($name, $arguments) { echo "Called method ".$name.", arguments count is: ".count($arguments);

结果是:
调用方法blabla,参数计数为:1


问题:为什么参数计数是
1
而不是
3
?我错在哪里?

脚本不计算数组中的项目,只计算参数号,唯一的参数是$arr

您需要使用以下方法计算项目:

     class My_class {

        public function __call($name, $arguments) {

            echo "Called method ".$name.", arguments count is: ".count($arguments);

        }


    }

    $obj = new My_class();

    $arr = array(1,2,3);

    $obj->blabla($arr); 

因为您正在传递单参数数组。如果你想要三个-使用
$obj->blablabla(1,2,3)
@J0HN调用它谢谢,(但是我需要更多的字符来发布这个)
count($arr);