utf8_(en|de)code removed from php7?

05/05/2020 22:00:01

I recently switched to PHP 7 on my development server, which has worked just fine - until now.

Since I updated to PHP 7.0.3-10+deb.sury.org~trusty+1 (earlier today), the utf8_decode and utf8_encode functions are no longer accessible. They were, however, in previous versions of PHP7. When called, a fatal error is raised.

I read that these functions are provided by the mbstring extension, which I checked with var_dump(extension_loaded('mbstring')); is loaded.

How can I get the above functions to work again?

Verified Answer (185 Votes)

04/28/2016 03:32:04

I had the same problem. Just install php7.0-xml package. Ubuntu 16.04:

sudo apt-get install php7.0-xml

Edit: Restart apache2 to load the new package.


Answer #2 (4 Votes)

03/18/2017 19:56:53

As the top voted answer did not work for me i found yet another package for php7 which (obvious by its name) fixed it for me

sudo apt-get install php7.0-mbstring

Answer #3 (3 Votes)

10/10/2016 18:10:38

If you are on CentOS, following command should work:

yum install php-xml
Hack Hex uses Stack Exchance API by the Stack Exchange Inc. to scrape questions/answers under Creative Commons license.