title besides title

 

Tuesday, November 27, 2012

PHP : Internationalization and Localization - [16.4] Setting the Default Locale

16.4.1 Problem

You want to set a locale that all your PHP programs can use.

16.4.2 Solution

At the beginning of a file loaded by the auto_prepend_file configuration directive, call setlocale( ) to set your desired locale:
setlocale(LC_ALL,'es_US');

16.4.3 Discussion

Even if you set up appropriate environment variables before you start your web server or PHP binary, PHP doesn't change its locale until you call setlocale( ). After setting environment variable LC_ALL to es_US, for example, PHP still runs in the default C locale.