lap*_*ete 8 php arrays reference
第197行的脚本'/usr/local/apache2/htdocs/read.php'发生错误:只应通过引用传递变量(第196行$ext = strtolower(array_pop(explode('.',$filename)));)
if(!function_exists('mime_content_type')) {
function mime_content_type($filename) {
$mime_types = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html', //ETC
);
$ext = strtolower(array_pop(explode('.',$filename)));
if (array_key_exists($ext, $mime_types)) {
return $mime_types[$ext];
}
elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mimetype;
}
else {
return 'application/octet-stream';
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用来自http://php.net/manual/en/function.mime-content-type.php的这个小脚本,虽然我遇到了一个我似乎无法弄清楚的致命错误.是否有任何人有这方面的经验并提出一些指示或指出我正确的方向?
Joh*_*hnP 10
在传递之前,您需要将explode()的结果变为变量
$var = explode('.',$filename);
$ext = strtolower(array_pop($var));
Run Code Online (Sandbox Code Playgroud)