4

I'm currently experiencing error on my application using php. here is the error message

Error - mPDF requires mb_string functions. Ensure that PHP is compiled with php_mbstring.dll enabled.

I'm using third party library to generate pdf file (MPDF). It works fine on my loaclhost (windows) but when we deploy it on the linux server, it throws the above error.

Can anyone help me on what's going on and how could I fix it. It seems that the php_mbstring.dll is missing on our linux server configuration.

Bryan
  • 1,245
  • 5
  • 22
  • 37

5 Answers5

4
if (!function_exists("mb_check_encoding")) {
    die('mbstring extension is not enabled');
}

And if you get that error, then rebuild PHP from source with mbstring enabled, or apt-get to include it in the build

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • 1
    sorry, but I want a resolution to fix error on linux and not to have a validation to check if mbstring is existing that may reports on MPDF doesn't work anymore – Bryan Oct 03 '12 at 12:53
  • 1
    The solution is only a look in the PHP docs away - http://www.php.net/manual/en/mbstring.installation.php – Mark Baker Oct 03 '12 at 12:54
  • It's quite simple - build PHP with mb_string on your linux box. – nickhar Oct 03 '12 at 12:55
  • The solution is to enable the mb_string extension on your linux. I wonder why it isn't there, it should be a no-go to use PHP without it, even if it is no default extension. – Sven Oct 03 '12 at 12:55
3

I was having the same problem on CentOS Linux. "yum install php-mbstring.x86_64" fixed it for me

3

Edit php.ini and extension=php_mbstring.dll remove the ;after which run the following commands

For php7.0 sudo apt-get install php7.0-mbstring For php5.6 sudo apt-get install php5.6-mbstring
worked for me :)

2

On Debian or Ubuntu, the mbstring package is not pulled in by default when you install php. You can fix this mPDF error with:

apt install php-mbstring
0

Find your php.ini, uncomment the line with the extension, and restart the server

Udit
  • 129
  • 2
  • 6