编程那点事编程那点事

专注编程入门及提高
探究程序员职业规划之道!

PHP提示Strict Standards: Only variables should be passed by reference in的解决方法

最近,在做大商创商城系统的二次开发,客户是医药行业的,需要传一些图片,比如药品经营许可证、GSP证。

在上传图片,取图片扩展名的时候,php报了以下错误:

Strict Standards: Only variables should be passed by reference in

查了相关资料说,PHP5.3以上默认只能传递具体的变量,而不能通过函数返回值传递,我的是php5.6,所以,肯定就报警告了。

我取图片后缀名的代码如下

$ext = array_pop(explode('.', $file['name']));

修改之后的代码

$extArr = explode('.', $file['name']);
$ext = array_pop($extArr);

通过以上的修改,Strict Standards: Only variables should be passed by reference in的问题就解决了。

当然,网上还有提议说把php.ini里面的error_reporting,改成error_reporting=E_ALL & ~E_STRICT,意思是显示所有除了严格模式的错误,编程入门认为这不是好方法,不推荐大家使用!

未经允许不得转载: 技术文章 » PHP编程 » PHP提示Strict Standards: Only variables should be passed by reference in的解决方法