PHP Fatal error: Class 'Collator' not found despite PHP 5.3.24

6k views Asked by At

my output after code below is: "PHP Fatal error: Class 'Collator' not found".

I've read in php manual that for COLLATOR class, PHP version needs to be PHP 5 >= 5.3.0. My PHP version is 5.3.24.

in my phpinfo() I searched 'coll' string but nothing is found.

also please note that my site lang is Turkish and I am using UTF-8

So what is the reason for my fatal error output? Thanks.

/* fetch values */
$etiket_bulutu = '';
while ($beyan->fetch()) 
{
    $etiket_bulutu .=  $tags.', ';
}

$etiket_bulutu = substr_replace($etiket_bulutu ,'',-2); //omit last {, } chars

$etiketler = explode(", ", $etiket_bulutu); //get each tag as arr

$etiketler = array_unique($etiketler);
$etiketler = array_values($etiketler); //only unique tags without NULLs

$etadet = count($etiketler);

$coll = collator_create('tr_TR'); //from http://www.php.net/manual/en/collator.sort.php
collator_sort($coll, $etiketler);

for($x=0;$x<$etadet;$x++)
 {
  echo $etiketler[$x];
  echo "<br />";
 }
2

There are 2 answers

1
deceze On BEST ANSWER

In the manual, note that the class is part of the intl extension. See the Installation Instructions for intl and note that it needs to be explicitly installed using --enable-intl and/or may require the ICU library, depending on the system. Check your PHP installation whether intl is installed or not.

0
Rodrigo On

Following a comment on the Installation Instructions for intl, all is needed in Debian today (just tested it) is:

sudo apt install php-intl
sudo service apache2 restart