mum
mum

Reputation: 1645

How install the mbstring extension in Centos?

I get the following fatal error:

Fatal error: Call to undefined function mb_convert_encoding() in /var/www/html/dai/components/com_servicemanager/views/i0602/view.html.php on line 67

I create a file CSV as :

<?php

$dateTimeNow = ...

$list = $this->get('DataCSV'); 

$filename = 'CSV_' . $dateTimeNow . '.csv';

foreach ($list as $item)
{ 
    $csv .= join("\t", $item)."\r\n"; 
}  

$csv = chr(255) .chr(254) . mb_convert_encoding($csv, "UTF-16LE", "UTF-8");


header("Content-type: application/x-msdownload");
header("Content-disposition: csv; filename=$filename; size=" . strlen($csv));
echo $csv;
exit;

I run on wamp on Window is Ok. But i put on server is Centos, it can't create file csv. Why ? Can you help me? thanks.

Upvotes: 2

Views: 13848

Answers (1)

hakre
hakre

Reputation: 197842

Turns out you have the mb_string function missing. Install it:

$ sudo yum install php-mbstring

That should fix the issue for you because it takes care installing the package.

For the undefined variable, you should see the same notice on windows as well when you enable error reporting.

Just initialize $csv before you add more to it:

$csv = '';
foreach ($list as $item)
{ 
    $csv .= join("\t", $item)."\r\n"; 
}

Upvotes: 6

Related Questions