6
votes

I have Ubuntu 16.04 installed, which comes with PHP 7 by default; but I ended up installing PHP 5.6 as well, and I have apache using 5.6.

When I went to run a project of mine, it told me the following:

PHP Fatal error: Call to undefined function utf8_encode()

I read through a bunch of posts where others have had this issue, and tried installing different extensions; but nothing has helped.

My understanding, was that that function would be packed with PHP (4,5,7) by default.

Any ideas?

* Update *

I did try the following, and it came back false.

var_dump(is_callable('utf8_encode'));

Here are the installed mods/extensions:

[PHP Modules] calendar Core ctype date dom ereg exif fileinfo filter ftp gettext hash iconv json libxml mbstring mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zlib

[Zend Modules] Zend OPcache

3
Was your PHP compiled with --disable-xml? Check your phpinfo().deceze♦
You should have a package called php5-xml or something similar. This function is part of the PHP XML parserMachavity♦
Maybe a silly question, it's installed but is it enabled? Try a2enmod / check mods-enabled folder to triple check!rjdown
Oooh I think I got it. I did sudo a2enmod xml2enc, and that fixed it.xil3
Wahey! Kinda weird it doesn't get enabled by default :|rjdown

3 Answers

32
votes

on ubuntu :

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

The following fixed it:

sudo a2enmod xml2enc

0
votes

On FreeBSD try this command

pkg install php71-tokenizer-7.1.25 php71-zlib-7.1.25