我有以下语句:
$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文档,mb_check_encoding
支持PHP 5>= 5.1.3。
我做错了什么?还是我的应用使用了旧版本的PHP?似乎不需要设置任何php.ini值来启用此功能。
感谢AJ。
$ yum install php-mbstring
或者重新加载apache:
$ systemctl reload apache2
感谢DCoder的指针和http://chrismcleod.me/2011/11/30/use-custom-php-extensions-on-heroku/上的教程,安装了mbstring。所以扩展可以在https://github.com/wuputah/heroku-libraries
这就解决了问题
将composer.json
添加到项目根目录,内容为:
{
"require": {
"ext-mbstring": "*"
}
}
更多信息https://devcenter.heroku.com/articles/php-support
我在Red Hat Linux上遇到了同样的问题。
您需要安装mbstring扩展。下面是安装的链接:
http://www.knowledgebase script.com/kb/article/how - -启用mbstring在php - 46. - html
这为我解决了这个问题。
谢谢
如果您是linux用户,则只需运行
sudo apt-get install php7.0-mbstring
这里只维护你的php版本,即php7.2-mbstring或php7.3-mbstring
不要忘记重启你的服务器,只要运行run:
sudo service apache2 restart