[英]Strict Standards: Only variables should be passed by reference - php error
$file_name = $_FILES['profile_image']['name'];
$file_ext = end(explode('.', $file_name)); //line 10
$file_ext = strtolower($file_ext);
$file_temp = $_FILES['profile_image']['tmp_name'];
Strict Standards: Only variables should be passed by reference in on line 10 严格标准:在第10行只能通过引用传递变量
How do I get rid of this error? 我该如何摆脱这个错误? Please and thank you :)
谢谢,麻烦您了 :)
end()
expects its parameter to be able to be passed by reference, and only variables can be passed by reference: end()
期望它的参数能够通过引用传递,并且只能通过引用传递变量:
$array = explode('.', $file_name);
$file_ext = end( $array);
You can fix this by saving the array to a variable first, then calling end()
. 您可以通过先将数组保存到变量,然后调用
end()
来解决此问题。
If you want the last item in the array, do this: 如果您想要数组中的最后一项,请执行以下操作:
$arr = explode(".", $file_name);
$file_ext = $arr[count($arr) - 1];
If you're trying to just get the extension from the file, use 如果您尝试从文件中获取扩展名,请使用
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
Actually, if you write $ext = end(explode('.', $filename)); 实际上,如果你写$ ext = end(explode('。',$ filename)); for getting the file extension then "Only variables should be passed by reference" can be show in php.
获取文件扩展名然后“只能通过引用传递变量”可以在php中显示。 For this reason, try to use it two steps, like: $tmp = explode('.', $filename);
出于这个原因,尝试使用它两个步骤,例如:$ tmp = explode('。',$ filename); $ext = end($tmp);
$ ext = end($ tmp);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.