7

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

xil3
  • 16,305
  • 8
  • 63
  • 97
  • Was your PHP compiled with `--disable-xml`? Check your `phpinfo()`. – deceze Jul 12 '16 at 19:36
  • Check what php extensions do you have. – u_mulder Jul 12 '16 at 19:36
  • Remove both versions of php and try installing again. That should solve it. – Nitin Jul 12 '16 at 19:36
  • I just removed all versions of php, and reinstalled 5.6, but still the same problem - http://stackoverflow.com/questions/36788873/package-php5-have-no-installation-candidate-ubuntu-16-04 – xil3 Jul 12 '16 at 19:47
  • 1
    You should have a package called `php5-xml` or something similar. This function is part of the PHP XML parser – Machavity Jul 12 '16 at 19:54
  • Just added the list of mods to the question. – xil3 Jul 12 '16 at 19:57
  • 1
    Maybe a silly question, it's installed but is it enabled? Try a2enmod / check mods-enabled folder to triple check! – rjdown Jul 12 '16 at 19:58
  • access_compat.load auth_basic.load authz_core.load autoindex.conf deflate.load env.load mime.load negotiation.conf php5.6.load status.conf alias.conf authn_core.load authz_host.load autoindex.load dir.conf filter.load mpm_prefork.conf negotiation.load setenvif.conf status.load alias.load authn_file.load authz_user.load deflate.conf dir.load mime.conf mpm_prefork.load php5.6.conf setenvif.load – xil3 Jul 12 '16 at 20:03
  • That's what is in the mods-enabled folder – xil3 Jul 12 '16 at 20:03
  • 1
    Oooh I think I got it. I did `sudo a2enmod xml2enc`, and that fixed it. – xil3 Jul 12 '16 at 20:05
  • 1
    Wahey! Kinda weird it doesn't get enabled by default :| – rjdown Jul 12 '16 at 20:06

3 Answers3

34

on ubuntu :

sudo apt-get install php5.6-xml 
sudo service apache2 restart
sj59
  • 2,072
  • 3
  • 22
  • 23
6

The following fixed it:

sudo a2enmod xml2enc

xil3
  • 16,305
  • 8
  • 63
  • 97
0

On FreeBSD try this command

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

Wendel086
  • 69
  • 1
  • 5