Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP 5.3 seems to be missing Intl extension by default

My system is Ubuntu 12.04, PHP 5.3, and I'm trying to run some basic Intl code like this:

<?php
$coll  = collator_create('en_US');
$result = collator_compare($coll, "string#1", "string#2");

and it outputs

PHP Fatal error:  Call to undefined function collator_create()

Wasn't Intl extension supposed to be bundled with PHP since version 5.3?

PHP was installed via apt-get with this command line (I don't use Apache):

apt-get install php5 php5-cli php5-mysql php5-cgi php5-fpm php5-curl php-apc php5-memcache php5-memcached php5-common php5-gd php-xml-parser php-pear php5-imap php5-mcrypt php5-xdebug php5-suhosin

And here is what php -v produces:

PHP 5.3.10-1ubuntu3.5 with Suhosin-Patch (cli) (built: Jan 18 2013 23:40:19) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
    with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH
like image 391
Desmond Hume Avatar asked Feb 21 '13 13:02

Desmond Hume


People also ask

What is Intl extension in PHP?

The Internationalization extension (Intl) is a wrapper for the ICU library, a set of C/C++ and Java libraries that provide Unicode and Globalization support for software applications. It enables PHP programmers to perform UCA-conformant collation and date/time/number/currency formatting in their scripts.


1 Answers

You have specify --enable-intl when installing to use the bundled version of intl, or you can install it via PECL. See: http://www.php.net/manual/en/intl.installation.php

apt-get install php5-intl will also work.

like image 58
Hans N. Hjort Avatar answered Sep 21 '22 11:09

Hans N. Hjort