Heroku:PHP有效函数的致命错误 - mb_check_encoding

时间:2012-12-26 10:06:04

标签: php heroku

我有以下声明:

$img->setTitle(mb_check_encoding($item['title'], 'UTF-8') ? $item['title'] : utf8_encode($item['title']));

这适用于PHP 5.4.17的本地设置和PHP 5.3.xx的共享主机

但是当我将此应用程序部署到Heroku(具有PHP 5.3.10)时,它会在日志中出现以下错误:

2012-12-26T09:55:28+00:00 app[web.1]: [Wed Dec 26 09:55:27 2012] [error] [client 10.119.79.71] PHP Fatal error: Call to undefined function mb_check_encoding() in /app/www/includes/utils.php on line 44, referer: https://imagemash.herokuapp.com/

根据php.net docs,PHP 5> = 5.1.3支持mb_check_encoding

我做错了什么?或者我的应用程序以某种方式使用旧版本的PHP?似乎没有任何php.ini值需要设置为启用此功能..

5 个答案:

答案 0 :(得分:4)

感谢DCoder的指针和http://chrismcleod.me/2011/11/30/use-custom-php-extensions-on-heroku/上的教程,安装了https://github.com/wuputah/heroku-libraries处提供的mbstring.so扩展

这解决了问题

答案 1 :(得分:4)

使用内容

composer.json添加到项目根目录
{
    "require": {
        "ext-mbstring": "*"
    }
}

更多信息https://devcenter.heroku.com/articles/php-support

答案 2 :(得分:3)

感谢AJ。

$ yum install php-mbstring

答案 3 :(得分:1)

我在Red Hat Linux上遇到了同样的问题。

您需要安装mbstring扩展名。以下是安装的链接:

http://www.knowledgebase-script.com/kb/article/how-to-enable-mbstring-in-php-46.html

这解决了我的问题。

谢谢

答案 4 :(得分:0)

如果您是Linux用户,则只需运行

sudo apt-get install php7.0-mbstring

这里只需维护您的php版本,即 php7.2-mbstring php7.3-mbstring

别忘了重新启动服务器,只需运行run即可重新启动:

sudo service apache2 restart