[doc-en] master: Document that Locale::parseLocale() uses the default locale on empty string (#5851)
| From: | Louis-Arnaud via GitHub | Date: | Thu, 10 Sep 2026 13:56:04 +0000 |
| Subject: | [doc-en] master: Document that Locale::parseLocale() uses the default locale on empty string (#5851) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23739@lists.php.net to get a copy of this message | ||
Author: Louis-Arnaud (lacatoire)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-09-10T15:56:00+02:00
Commit: https://github.com/php/doc-en/commit/815ee7695d8cd08a613bd94b9e52eae6692f77a8
Raw diff: https://github.com/php/doc-en/commit/815ee7695d8cd08a613bd94b9e52eae6692f77a8.diff
Document that Locale::parseLocale() uses the default locale on empty string (#5851)
* Document that Locale::parseLocale() uses the default locale on empty string
* Fix arrow notation in returnvalues (variant0=>varX)
* Add example showing empty string uses the default locale
* Move example output outside <example> element (convention)
Changed paths:
M reference/intl/locale/parse-locale.xml
Diff:
diff --git a/reference/intl/locale/parse-locale.xml b/reference/intl/locale/parse-locale.xml
index e10c2ff5b7b0..0a2e68db99d2 100644
--- a/reference/intl/locale/parse-locale.xml
+++ b/reference/intl/locale/parse-locale.xml
@@ -35,11 +35,12 @@
<varlistentry>
<term><parameter>locale</parameter></term>
<listitem>
- <para>
+ <simpara>
The locale to extract the subtag array from. Note: The 'variant' and
'private' subtags can take maximum 15 values whereas 'extlang' can take
- maximum 3 values.
- </para>
+ maximum 3 values. If an empty string is passed, the value returned by
+ <function>locale_get_default</function> is used instead.
+ </simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -48,18 +49,15 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
- <para>
+ <simpara>
Returns an array containing a list of key-value pairs, where the keys
identify the particular locale ID subtags, and the values are the
associated subtag values. The array will be ordered as the locale id
- subtags e.g. in the locale id if variants are '-varX-varY-varZ' then the
- returned array will have variant0=>varX , variant1=>varY ,
- variant2=>varZ
- </para>
- <para>
- Returns &null; when the length of <parameter>locale</parameter> exceeds
- <constant>INTL_MAX_LOCALE_LEN</constant>.
- </para>
+ subtags e.g. in the locale id if variants are <literal>-varX-varY-varZ</literal>
then the
+ returned array will have <literal>variant0=>varX</literal>,
+ <literal>variant1=>varY</literal>,
<literal>variant2=>varZ</literal>.
+ </simpara>
+ &intl.locale-len.return;
</refsect1>
<refsect1 role="examples">
@@ -98,6 +96,28 @@ if ($arr) {
<screen>
<![CDATA[
language : sl , script : Latn , region : IT , variant0 : NEDIS ,
+]]>
+ </screen>
+ <example>
+ <title>Empty string uses the default locale</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+locale_set_default('fr-Latn-FR');
+$arr = locale_parse('');
+if ($arr) {
+ foreach ($arr as $key => $value) {
+ echo "$key : $value , ";
+ }
+}
+?>
+]]>
+ </programlisting>
+ </example>
+ &example.outputs;
+ <screen>
+<![CDATA[
+language : fr , script : Latn , region : FR ,
]]>
</screen>
</refsect1>
@@ -107,6 +127,8 @@ language : sl , script : Latn , region : IT , variant0 : NEDIS ,
<para>
<simplelist>
<member><function>locale_compose</function></member>
+ <member><function>locale_get_default</function></member>
+ <member><function>locale_set_default</function></member>
</simplelist>
</para>
</refsect1>