utf8_(en|de)code removed from php7?

PhpUtf 8Mbstring

Php Problem Overview


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?

Php Solutions


Solution 1 - Php

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.

Solution 2 - Php

On Ubuntu, you got the following message during the upgrade of PHP7:

php7.0 (7.0.3-6) unstable; urgency=medium

  * Several extensions have been split into separate extension packages:
   - php-dba - Database (dbm-style) Abstraction Layer
   - php-mbstring - Multibyte String
   - php-soap - SOAP
   - php-xml - DOM, SimpleXML, WDDX, XML, XMLReader and XMLWriter
   - php-zip - Zip
  * The new packages are not installed automatically, so you will need to
    install them by hand, if you use the functions in those modules.
  * Most modules that have been builtin before are now included in
    php7.0-common package and they are enabled by default for your
    convenience.  You can disable unneede modules via phpdismod tool.

 -- Ondřej Surý <[email protected]>  Mon, 22 Feb 2016 12:37:09 +0100

so it's one of those packages that's causing the problem. In this case, it's php-xml.

Note the

> The new packages are not installed automatically

You can fix that by

sudo apt-get install php-xml
sudo apache2ctl graceful

Solution 3 - Php

If you are on CentOS, following command should work:

yum install php-xml

Solution 4 - Php

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

Solution 5 - Php

In Ubuntu 16.04 LTS, with php 5.6, try:

sudo apt-get install php5.6-xml
sudo service apache2 restart

Solution 6 - Php

The utf8_decode and utf8_encode functions are accessible in php 7:

function.utf8-encode - manual - php

This is because the php-xml package is missing in your php installation.

If your server is running Mandrake, enter "urpmi php-xml".

If your server is running EASYPHP on Windows, click on the EASYPHP logo to activate the php-xml module.

On debian or ubuntu try :

apt-get install php7.0-xmlrpc

Solution 7 - Php

I encountered the same problem and for me,

sudo apt-get install php-patchwork-utf8

and restarting the apache2 server solved the problem (on Ubuntu 16.04 LTS).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpaoloView Question on Stackoverflow
Solution 1 - PhpVladimir KorshunovView Answer on Stackoverflow
Solution 2 - PhpThomas WellerView Answer on Stackoverflow
Solution 3 - PhpWaqar AlamgirView Answer on Stackoverflow
Solution 4 - PhpGuenther SchmitzView Answer on Stackoverflow
Solution 5 - PhpRômulo Z. C. CunhaView Answer on Stackoverflow
Solution 6 - PhpDevLootsView Answer on Stackoverflow
Solution 7 - Phpjk - Reinstate MonicaView Answer on Stackoverflow