只有变量可以通过引用错误传递 [英] Only Variables can be passed by reference error

查看:129
本文介绍了只有变量可以通过引用错误传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在脚本'/usr/local/apache2/htdocs/read.php发生在行197错误:只有变量应该按引用传递(行196 $分机=用strtolower(array_pop(爆炸(,$文件名'。')));

An error occurred in script '/usr/local/apache2/htdocs/read.php' on line 197: Only variables should be passed by reference (line 196 is $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';
        }
    }
}

我使用的是从这个小脚本<一个href=\"http://php.net/manual/en/function.mime-content-type.php\">http://php.net/manual/en/function.mime-content-type.php,虽然我得到一个致命的错误,我似乎无法弄清楚。这是否有经验,用这个和任何人提供一些线索或点我在正确的方向?

I'm using this little script from http://php.net/manual/en/function.mime-content-type.php, though I'm getting a fatal error I can't seem to figure out. Does anyone that has experience with this and shed some light or point me in the right direction?

推荐答案

您需要做的爆炸()的结果变量,你通过它

You need to make the result of explode() a variable before you pass it on

$var = explode('.',$filename);
$ext = strtolower(array_pop($var));

这篇关于只有变量可以通过引用错误传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆