mb_convert_encoding, undefined function while mbstring is enabled

强颜欢笑 提交于 2019-11-30 07:47:05

问题


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.

However, when I look in phpinfo(), I see that multibyte support is enabled.

I've tried things like apt-get install php5-mbstring, php-mbstring, php-multibyte, etc. etc. but none seem to work.

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)

./configure --enable-mbstring

The weird this is, phpinfo() already showed that it was enabled. I don't know why it didn't work before :/


回答1:


A lot of newer Linux servers do not have PHP Multibyte modules installed by default. A simple solution is often to install php-mbstring.

On Red Hat flavors (CentOS, Fedora, etc.) you can use yum install php-mbstring.

Make sure you restart your Apache server afterwards. Use service httpd restart on RH flavors.




回答2:


In the case of your installation is php5.6 is similar to solution of 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 php5.6-mbstring

and then restart apache service

sudo service apache2 restart.



回答3:


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.

It looks like PHP mbstring not installed on your server.

Solution :

In my case I have just uncomment ;extension=php_mbstring.dll in php.ini file and issue has been resolved.

Don't forget to restart apache server after uncomment ;extension=php_mbstring.dll

Code taken from this blog: http://chandreshrana.blogspot.in/2016/01/call-to-undefined-function.html



来源:https://stackoverflow.com/questions/8266396/mb-convert-encoding-undefined-function-while-mbstring-is-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!