Can the PHP setLocale () be used to set the locale on a connection-based level, or it only sets it on a wider level, such as thread-level, process-level, or even server-level?
I would like to know the question for Linux and windows separately.
regards
safety of setLocale
Moderator: General Moderators
php setlocale is just a wrapper to setlocale defined in Standard C library. Therefore it's platform-dependent. I'd recommend to use the following script to test if certain implementation is thread-safe:feyd wrote:considering how most php scripts are processed, I'd say it's per page request.
Code: Select all
set_time_limit(0);
$locales = array(
'C',
'POSIX',
'pt_PT.ISO8859-1',
'ru_RU.KOI8-R',
'es-ES',
//... and so forth
// adjust this array for particular system
);
$localeset = setlocale(LC_ALL, $locales[rand(0, count($locales)-1)]);
sleep(20); // wait for operator to run several instances
if(setlocale(LC_ALL, "0") != $localeset) {
echo "<b>Your server isn't thread-safe</b>";
} else {
echo "<b>Your server is thread-safe</b>";
}