PHP中的函数已弃用,现在应该使用什么? [英] Function in PHP deprecated, what should I use now?

查看:225
本文介绍了PHP中的函数已弃用,现在应该使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个班上有这段代码

I have this code in one of my classes

 public function __call($method, $args) {

        array_unshift($args, $method);

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

    }

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

We've since switched servers, and they must use a newer version of PHP5, and I get the following message

Function call_user_method_array() is deprecated

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

Is there where I should use reflection? What exactly is it, and how would I use it to modify my code above to work as it used to?

推荐答案

从PHP 4.1.0开始不推荐使用call_user_method_array()函数.

The call_user_method_array() function is deprecated as of PHP 4.1.0.

新方法:

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

这篇关于PHP中的函数已弃用,现在应该使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆