简体   繁体   English

Strct标准:仅变量应通过引用传递

[英]Strct standards: Only variables should be passed by reference

I have this code 我有这个代码

$maxSize="44400000";
$allowedExts = array("jpg","jpeg","docx","png","JPG");
$extension = end(explode(".", $_FILES["file"]["name"])); 

and giving me error shown below. 并给我下面显示的错误。

The Main problem is with the above line. 主要问题是上述行。

Strict standards: Only variables should be passed by reference 严格的标准:只能通过引用传递变量

You have to create one more variable: 您必须再创建一个变量:

$maxSize="44400000";
$allowedExts = array("jpg","jpeg","docx","png","JPG");
$extension = explode(".", $_FILES["file"]["name"]);
$final_ext = end($extension);

But it's better to use pathinfo to do this. 但是最好使用pathinfo来做到这一点。

$path = $_FILES['file']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);

As end function only accepts argument that must be passed by reference you should do this : 由于最终函数仅接受必须通过引用传递的参数,因此您应该这样做:

$maxSize="44400000";
$allowedExts = array("jpg","jpeg","docx","png","JPG");
$explode = explode(".", $_FILES["file"]["name"]);
$extension = end($explode);

read more http://php.net/manual/en/function.end.php 了解更多http://php.net/manual/zh/function.end.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM