1.2.1096. Setlocale() Uses Constants¶
setlocale() don’t use strings but constants.
The first argument of setlocale() must be one of the valid constants, LC_ALL
, LC_COLLATE
, LC_CTYPE
, LC_MONETARY
, LC_NUMERIC
, LC_TIME, `LC_MESSAGES <https://www.php.net/LC_MESSAGES>`_
.
The PHP 5 usage of strings (same name as above, enclosed in ‘ or “) is not legit anymore in PHP 7 and later.
<?php
// Use constantes for setlocale first argument
setlocale(LC_ALL, 'nl_NL');
setlocale(\LC_ALL, 'nl_NL');
// Don't use string for setlocale first argument
setlocale('LC_ALL', 'nl_NL');
setlocale('LC_'.'ALL', 'nl_NL');
?>
See also setlocale.
1.2.1096.1. Suggestions¶
Use setlocale() constants
1.2.1096.2. Specs¶
Short name |
Structures/SetlocaleNeedsConstants |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Available in |