PHP 8.5.0 Alpha 1 available for testing

Voting

: two plus one?
(Example: nine)

The Note You're Voting On

internationalist
9 years ago
My script runs a loop that changes the locale (multilingual application). I've noticed that on some random occasion the locale still hasn't changed despite the setlocale() function being executed a step earlier. I had to add wait time for this condition. Interestingly enough, this was the case only with the 'nl_NL.UTF8' locale.

<?php
//some code
$this->counter = 0;
// some code
$this->locale = 'nl_NL.UTF8';
setlocale(LC_ALL, $this->locale);
$this->counter++;
if (
$this->locale !== setlocale(LC_CTYPE, 0)) { // Locale not changed yet.
if ($this->counter > 10) {
return;
}
sleep(1);
}
// some code
?>

<< Back to user notes page

To Top