PHP 5.3 can't find normalizer_normalize()
Asked Answered
G

2

8

I am trying to use the normalizer_normalize() function introduced in PHP 5.3 (says the doc), however I can't use it:

$ php -r 'echo normalizer_normalize("tést");'
PHP Fatal error:  Call to undefined function normalizer_normalize()
in Command line code on line 1

I've checked my PHP version but it's 5.3:

$ php --version
PHP 5.3.6 (cli) (built: Sep 12 2011 18:02:42)

I don't understand why PHP can't find it?

Gama answered 21/1, 2012 at 0:32 Comment(0)
P
9

Normalizer is part of the intl extension. While it's built by default, that does not necessarily mean that the specific version of PHP that you are using has it installed or enabled by default.

If you're getting your PHP version from your operating system, check to see if the package manager has a package named php-intl. If not, check for php-pecl-intl. If you're using RHEL/CentOS/Scientific Linux 5.x, also look for php53-intl.

Phallus answered 21/1, 2012 at 0:36 Comment(2)
OK thank you it's not installed indeed. Do you know any replacement for this without the php-intl extension?Gama
Unfortunately I know of no other alternatives that are native to PHP.Phallus
D
0

I wanted to give a modern, up-to-date answer, as things seem to have changed a bit since 2012. Using Ubuntu 20.04 and PHP8.1, I was able to get this to work with just...

sudo apt-get install php8.0-intl

Don't forget to do a full apache restart afterwards (either one of these should do it)...

systemctl restart apache2
/etc/init.d/apache2 restart

In addition, this automatically installed the updated 8.1-version...

root@ dpkg --list | grep 'intl'
ii  php8.0-intl                     1:8.0.21-2+ubuntu20.04.1+deb.sury.org+1      amd64        Internationalisation module for PHP
ii  php8.1-intl                     8.1.8-1+ubuntu20.04.1+deb.sury.org+1         amd64        Internationalisation module for PHP
Dovetailed answered 14/8, 2022 at 16:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.