我有这段代码来获取文件的扩展名:
$extension = end(explode(".", $_FILES["rfile"]["name"]));
这在localhost上运行正常,但是当我上传在线托管时,它给了我这个错误:
严格标准:只有变量才能通过引用传递给......
答案 0 :(得分:8)
答案 1 :(得分:6)
PHP end
将变量的引用作为参数。
http://php.net/manual/en/function.end.php
因此,在启用严格标准的情况下,您应该首先将explode
的结果放入变量中:
$exp = explode(".", $_FILES["rfile"]["name"])
$extension = end($exp);
答案 2 :(得分:2)
您的localhost是旧的PHP版本,或者未配置为显示严格的标准错误。
现在在PHP中,你应该这样做:
$explode = explode(".", $_FILES["rfile"]["name"]);
$extension = end($explode);
请参阅文档中的示例:http://php.net/manual/en/function.end.php#refsect1-function.end-examples