Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mb_convert_encoding error: Call to undefined function mb_convert_encoding()

Tags:

php

I am currently writing a PHP function but when the complete script is executed I am getting an error:

Error:

Call to undefined function mb_convert_encoding() 

My function:

function cleanData(&$str)
  {
   if($str == 't') $str = 'TRUE';
   if($str == 'f') $str = 'FALSE';
   if(preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) {
   $str = "'$str";
  }
  if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
  $str = mb_convert_encoding($str, 'ISO-8859-1','utf-8');
}

Can anyone see where I am going wrong. Many thanks in advance for your time.

Cheers

like image 354
DCJones Avatar asked May 25 '16 15:05

DCJones


2 Answers

You need to install the extension. It depends on of your operating system, here are some examples:

sudo apt-get install php-mbstring  # Debian, Ubuntu
sudo yum install php-mbstring  # RedHat, Fedora, CentOS
like image 196
Jorge Barata Avatar answered Nov 16 '22 08:11

Jorge Barata


On Windows, uncomment the following line in php.ini, and restart the Apache server:

extension=mbstring

If you still get the error afterwards, make sure that what you see is not cached response.

like image 40
user Avatar answered Nov 16 '22 08:11

user