mb_convert_encoding, undefined function while mbstring is enabled

Harold picture Harold · Nov 25, 2011 · Viewed 67k times · Source

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 :/

Answer

Lance Cleveland picture Lance Cleveland · Nov 1, 2013

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.