reference/strings/functions/setlocale.xml
54ff7bf8e0f8fa90988cccf6b583517366605f6d
...
...
@@ -9,19 +9,32 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>string</type><methodname>setlocale</methodname>
12
+
<type class="union"><type>string</type><type>false</type></type><methodname>setlocale</methodname>
13
13
<methodparam><type>int</type><parameter>category</parameter></methodparam>
14
-
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
15
-
<methodparam choice="opt"><type>string</type><parameter>...</parameter></methodparam>
14
+
<methodparam><type>string</type><parameter>locales</parameter></methodparam>
15
+
<methodparam rep="repeat"><type>string</type><parameter>rest</parameter></methodparam>
16
16
</methodsynopsis>
17
+
<simpara>Alternative signature (not supported with named arguments):</simpara>
17
18
<methodsynopsis>
18
-
<type>string</type><methodname>setlocale</methodname>
19
+
<type class="union"><type>string</type><type>false</type></type><methodname>setlocale</methodname>
19
20
<methodparam><type>int</type><parameter>category</parameter></methodparam>
20
-
<methodparam><type>array</type><parameter>locale</parameter></methodparam>
21
+
<methodparam><type>array</type><parameter>locale_array</parameter></methodparam>
21
22
</methodsynopsis>
22
23
<para>
23
24
Sets locale information.
24
25
</para>
26
+
<warning>
27
+
<para>
28
+
The locale information is maintained per process, not per thread. If you
29
+
are running PHP on a multithreaded server API
30
+
, you may experience sudden changes in locale settings while a
31
+
script is running, though the script itself never called
32
+
<function>setlocale</function>. This happens due to other scripts
33
+
running in different threads of the same process at the same time,
34
+
changing the process-wide locale using <function>setlocale</function>.
35
+
On Windows, locale information is maintained per thread as of PHP 7.0.5.
36
+
</para>
37
+
</warning>
25
38
</refsect1>
26
39

27
40
<refsect1 role="parameters">
...
...
@@ -49,7 +62,7 @@
49
62
<listitem>
50
63
<simpara>
51
64
<constant>LC_CTYPE</constant> for character classification and conversion, for
52
-
example <function>strtoupper</function>
65
+
example <function>ctype_alpha</function>
53
66
</simpara>
54
67
</listitem>
55
68
<listitem>
...
...
@@ -80,21 +93,21 @@
80
93
</listitem>
81
94
</varlistentry>
82
95
<varlistentry>
83
-
<term><parameter>locale</parameter></term>
96
+
<term><parameter>locales</parameter></term>
84
97
<listitem>
85
98
<para>
86
-
If <parameter>locale</parameter> is &null; or the empty string
99
+
If <parameter>locales</parameter> is the empty string
87
100
<literal>""</literal>, the locale names will be set from the
88
101
values of environment variables with the same names as the above
89
102
categories, or from "LANG".
90
103
</para>
91
104
<para>
92
-
If <parameter>locale</parameter> is <literal>"0"</literal>,
105
+
If <parameter>locales</parameter> is <literal>"0"</literal>,
93
106
the locale setting is not affected, only the current setting is returned.
94
107
</para>
95
108
<para>
96
-
If <parameter>locale</parameter> is an array or followed by additional
97
-
parameters then each array element or parameter is tried to be set as
109
+
If <parameter>locales</parameter> is followed by additional
110
+
parameters then each parameter is tried to be set as
98
111
new locale until success. This is useful if a locale is known under
99
112
different names on different systems or for providing a fallback
100
113
for a possibly not available locale.
...
...
@@ -102,11 +115,22 @@
102
115
</listitem>
103
116
</varlistentry>
104
117
<varlistentry>
105
-
<term><parameter>...</parameter></term>
118
+
<term><parameter>rest</parameter></term>
119
+
<listitem>
120
+
<para>
121
+
Optional string parameters to try as locale settings until
122
+
success.
123
+
</para>
124
+
</listitem>
125
+
</varlistentry>
126
+
<varlistentry>
127
+
<term><parameter>locale_array</parameter></term>
106
128
<listitem>
107
129
<para>
108
-
(Optional string or array parameters to try as locale settings until
109
-
success.)
130
+
Each array element is tried to be set as
131
+
new locale until success. This is useful if a locale is known under
132
+
different names on different systems or for providing a fallback
133
+
for a possibly not available locale.
110
134
</para>
111
135
</listitem>
112
136
</varlistentry>
...
...
@@ -142,32 +166,6 @@
142
166
</note>
143
167
</refsect1>
144
168

145
-
<refsect1 role="changelog">
146
-
&reftitle.changelog;
147
-
<para>
148
-
<informaltable>
149
-
<tgroup cols="2">
150
-
<thead>
151
-
<row>
152
-
<entry>&Version;</entry>
153
-
<entry>&Description;</entry>
154
-
</row>
155
-
</thead>
156
-
<tbody>
157
-
<row>
158
-
<entry>5.3.0</entry>
159
-
<entry>
160
-
This function now throws an <constant>E_DEPRECATED</constant> notice if a string is passed
161
-
to the <parameter>category</parameter> parameter instead of one of the
162
-
<literal>LC_*</literal> constants.
163
-
</entry>
164
-
</row>
165
-
</tbody>
166
-
</tgroup>
167
-
</informaltable>
168
-
</para>
169
-
</refsect1>
170
-

171
169
<refsect1 role="examples">
172
170
&reftitle.examples;
173
171
<para>
...
...
@@ -182,7 +180,7 @@ setlocale(LC_ALL, 'nl_NL');
182
180
/* Output: vrijdag 22 december 1978 */
183
181
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
184
182

185
-
/* try different possible locale names for german as of PHP 4.3.0 */
183
+
/* try different possible locale names for german */
186
184
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
187
185
echo "Preferred locale for german on this system is '$loc_de'";
188
186
?>
...
...
@@ -202,7 +200,7 @@ setlocale(LC_ALL, 'nld_nld');
202
200
/* Output: vrijdag 22 december 1978 */
203
201
echo strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));
204
202

205
-
/* try different possible locale names for german as of PHP 4.3.0 */
203
+
/* try different possible locale names for german */
206
204
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
207
205
echo "Preferred locale for german on this system is '$loc_de'";
208
206
?>
...
...
@@ -214,21 +212,10 @@ echo "Preferred locale for german on this system is '$loc_de'";
214
212

215
213
<refsect1 role="notes">
216
214
&reftitle.notes;
217
-
<warning>
218
-
<para>
219
-
The locale information is maintained per process, not per thread. If you
220
-
are running PHP on a multithreaded server API like IIS or Apache on
221
-
Windows, you may experience sudden changes in locale settings while a
222
-
script is running, though the script itself never called
223
-
<function>setlocale</function>. This happens due to other scripts
224
-
running in different threads of the same process at the same time,
225
-
changing the process-wide locale using <function>setlocale</function>.
226
-
</para>
227
-
</warning>
228
215
<tip>
229
216
<para>
230
217
Windows users will find useful information about
231
-
<parameter>locale</parameter> strings at Microsoft's
218
+
<parameter>locales</parameter> strings at Microsoft's
232
219
<acronym>MSDN</acronym> website. Supported language strings can be found
233
220
in the
234
221
<link xlink:href="&url.setlocale.lang.win32;">language strings documentation</link>
...
...
@@ -239,7 +226,6 @@ echo "Preferred locale for german on this system is '$loc_de'";
239
226
</refsect1>
240
227

241
228
</refentry>
242
-

243
229
<!-- Keep this comment at the end of the file
244
230
Local variables:
245
231
mode: sgml
246
232