5

我的一门课中有这段代码

 public function __call($method, $args) {

        array_unshift($args, $method);

        call_user_method_array('view', $this, $args);

    }

我们已经切换了服务器,他们必须使用更新版本的 PHP5,我收到以下消息

Function call_user_method_array() is deprecated

我应该在哪里使用反射?它到底是什么,我将如何使用它来修改我上面的代码以像以前一样工作?

4

1 回答 1

24

http://php.net/manual/en/function.call-user-method-array.php

call_user_method_array() 函数自 PHP 4.1.0 起已弃用。

新的方法:

<?php
// Old:
// call_user_method_array('view', $this, $args);
// New:
call_user_func_array(array($this, 'view'), $args);
?>
于 2010-01-27T23:29:19.060 回答