php mb_convert_encoding,启用 mbstring 时未定义的函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8266396/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mb_convert_encoding, undefined function while mbstring is enabled
提问by Harold
I have a server (Ubuntu 11.10 x64) running PHP 5.3.8 with Apache2 / MySQL. I'm currently working on a project where I'm required to do some specific character encoding, but I found out that none of the multibyte (mb_* functions) are working.
我有一台运行 PHP 5.3.8 和 Apache2/MySQL 的服务器(Ubuntu 11.10 x64)。我目前正在做一个项目,我需要做一些特定的字符编码,但我发现没有一个多字节(mb_* 函数)在工作。
However, when I look in phpinfo(), I see that multibyte support is enabled.
但是,当我查看 phpinfo() 时,我看到启用了多字节支持。
I've tried things like apt-get install php5-mbstring, php-mbstring, php-multibyte, etc. etc. but none seem to work.
我尝试过 apt-get install php5-mbstring、php-mbstring、php-multibyte 等,但似乎都不起作用。
Can anyone point me in the right direction for this? Thanks in advance!
任何人都可以指出我正确的方向吗?提前致谢!
edit: Fixed it by recompiling PHP (this was my last resort, which I initially wanted to avoid)
编辑:通过重新编译 PHP 修复它(这是我最后的手段,我最初想避免)
./configure --enable-mbstring
./configure --enable-mbstring
The weird this is, phpinfo() already showed that it was enabled. I don't know why it didn't work before :/
奇怪的是,phpinfo() 已经显示它已启用。我不知道为什么它以前不起作用:/
回答by Lance Cleveland
A lot of newer Linux servers do not have PHP Multibyte modules installed by default. A simple solution is often to install php-mbstring.
许多较新的 Linux 服务器默认没有安装 PHP 多字节模块。一个简单的解决方案通常是安装 php-mbstring。
On Red Hat flavors (CentOS, Fedora, etc.) you can use yum install php-mbstring.
在 Red Hat 版本(CentOS、Fedora 等)上,您可以使用 yum install php-mbstring。
Make sure you restart your Apache server afterwards. Use service httpd restart on RH flavors.
确保之后重新启动 Apache 服务器。在 RH 版本上使用 service httpd restart。
回答by Ken Thompson
In the case of your installation is php5.6 is similar to solution of neilsimp1:
在你安装的是php5.6的情况下类似于neilsimp1的解决方案:
Running sudo apt-get install php7.0-mbstring
and then sudo service php7.0-fpm
restart did the trick for me.
运行sudo apt-get install php7.0-mbstring
然后sudo service php7.0-fpm
重新启动对我来说很有效。
sudo apt-get install php5.6-mbstring
and then restart apache service
然后重启apache服务
sudo service apache2 restart.
回答by Chandresh
Sometimes people receiving this kind of error : Fatal error: Call to undefined function mb_convert_encoding() in /public_html/this/this.php at line 188. Normally this kind of errors comes in PHP Sites and PHP framework aswell.
有时人们会收到这种错误:致命错误:在第 188 行调用 /public_html/this/this.php 中未定义的函数 mb_convert_encoding()。通常这种错误也出现在 PHP 站点和 PHP 框架中。
It looks like PHP mbstring not installed on your server.
您的服务器上似乎没有安装 PHP mbstring。
Solution :
解决方案 :
In my case I have just uncomment ;extension=php_mbstring.dll in php.ini file and issue has been resolved.
就我而言,我刚刚取消了 php.ini 文件中的 ;extension=php_mbstring.dll 注释,问题已解决。
Don't forget to restart apache server after uncomment ;extension=php_mbstring.dll
取消注释后不要忘记重启apache服务器;extension=php_mbstring.dll
Code taken from this blog: http://chandreshrana.blogspot.in/2016/01/call-to-undefined-function.html
取自此博客的代码:http: //chandreshrana.blogspot.in/2016/01/call-to-undefined-function.html