我在一个类有这段代码

 public function __call($method, $args) {

        array_unshift($args, $method);

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

    }

此后,我们已经切换了服务器,并且它们必须使用较新版本的PHP5,并且我收到以下消息



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

最佳答案

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



新方法:

<?php
// Old:
// call_user_method_array('view', $this, $args);
// New:
call_user_func_array(array($this, 'view'), $args);
?>

关于php - PHP中的函数已弃用,现在应该使用什么?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2151125/

10-12 13:06