MAMP 1.9 Pro PHP 5.2.13 无法识别 mime_content_type()
我是 PHP 和 MAMP 新手。我有一个我支持的 PHP 5.2.13 站点,它调用 mime_content_type() 函数,但该函数在我的计算机上无法识别。我不断收到此消息:
致命错误:调用未定义的函数 mime_content_type()
谷歌都说有关“mime magic”的难以理解的事情。我需要在 MAMP PHP 实例中安装一些扩展才能识别 mime_content_type() 吗?
I'm a PHP and MAMP newbie. I've got a PHP 5.2.13 site I'm supporting which calls out to the mime_content_type() function, but that function is not recognized on my machine. I keep getting this:
Fatal error: Call to undefined function mime_content_type()
The googles all say indecipherable things about "mime magic". Is there some extension I need to install in my MAMP PHP instance so that mime_content_type() will be recognized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
函数
mime_content_type
已弃用,取而代之的是 Fileinfo,这是一个 PECL 扩展,最近已移至 PHP 源代码中。您可以尝试使用 Fileinfo 看看是否可用;从 PHP 5.3.0 开始默认安装它。但是,如果您使用的是旧版本或更改了某些配置或其他内容,则可能必须安装它。尝试下面的代码。如果有效,那么你就完成了;如果没有,您必须安装 Fileinfo。 此处描述了该包。
使用 Fileinfo,您可以将
$type=mime_content_type($filename)
替换为:The function
mime_content_type
is deprecated in favor of Fileinfo, which is a PECL extension that has recently been moved into PHP's source. You can try using Fileinfo and see if it's available; it's installed by default since PHP 5.3.0. However, if you're using an older version or changed some configuration or something, you might have to install it.Try the code below. If it works, you're done; if it doesn't, you'll have to install Fileinfo. The package is described here.
Using Fileinfo, you would replace
$type=mime_content_type($filename)
, for example, with:它已经被弃用了一段时间了。
您最好编写自己的函数,或者从 php.net
It's been deprecated for a while now.
You're better off writing your own function, or taking some hints from the docs and comments on php.net