note 123811 added to function.setlocale
| From: | tim dot peters at live dot com | Date: | Wed, 01 May 2019 09:18:42 +0000 |
| Subject: | note 123811 added to function.setlocale | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210878@lists.php.net to get a copy of this message | ||
Maybe obvious, but I would expect that setlocale constantes (LC_*) would be bitwise, but
they're not.
In example, doing this:
<?php
setlocale(LC_TIME + LC_COLLATE, 'nl');
echo setlocale(LC_ALL, 0);
?>
would cause the following result:
LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=nl;LC_PAPER=C;
LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C
Note that LC_MESSAGES has changed, instead of LC_TIME and LC_COLLATE. (Because LC_TIME + LC_COLLATE
= LC_MESSAGES).
Instead you would need to specify them individually, if you don't wish to use LC_ALL:
<?php
setlocale(LC_TIME, 'nl');
setlocale(LC_COLLATE, 'nl');
echo setlocale(LC_ALL, 0);
?> LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=nl;LC_COLLATE=nl;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;
LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.195 (proxied: 77.251.29.46)
----
Manual Page -- http://php.net/manual/en/function.setlocale.php
Edit -- https://master.php.net/note/edit/123811
Del: integrated -- https://master.php.net/note/delete/123811/integrated
Del: useless -- https://master.php.net/note/delete/123811/useless
Del: bad code -- https://master.php.net/note/delete/123811/bad+code
Del: spam -- https://master.php.net/note/delete/123811/spam
Del: non-english -- https://master.php.net/note/delete/123811/non-english
Del: in docs -- https://master.php.net/note/delete/123811/in+docs
Del: other reasons-- https://master.php.net/note/delete/123811
Reject -- https://master.php.net/note/reject/123811
Search -- https://master.php.net/manage/user-notes.php