$allowed=array('jpg','jpqg','gif','png','JPG','JPEG','GIF','PNG');
$file_name=$_FILES['profile']['name'];
$file_extn= end(explode('.',$file_name));
$file_temp=$_FILES['profile']['tmp_name'];
if(in_array($file_extn,$allowed) == true) {
//change_profile_image($_SESSION['id'],$file_temp);
}
else {
echo'incorrect file type .Allowed:';
echo implode(', ',$allowed);
}
错误是:
严格的标准:只有变量应该通过引用传递
当我使用结束函数时收到此错误
要获取文件扩展名,请使用如下:
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
警告消息说明了一切。在使用end
之前,必须将分解结果存储在变量中
例如:
$pieces = explode('.',$file_name);
$file_extn= end($pieces);
~编辑:
end
函数将参数作为引用。这意味着函数使用内存地址而不是值。这就是为什么我们必须将explode
的回报存储在变量中。
您可以在此链接中阅读有关通过引用传递的更多信息:http://php.net/manual/en/language.references.pass.php
这是end
文档:http://php.net/manual/en/function.end.php