[DOC-CVS] [doc-en] master: document setlocale(LC_ALL, null) to retrieve current setting (#4765)

[email protected] (Remi Collet via GitHub)
Newsgroups php.doc.cvs
Message-ID <[email protected]>
Author: Remi Collet (remicollet)
Committer: GitHub (web-flow)
Pusher: remicollet
Date: 2025-07-11T06:43:29+02:00

Commit: https://github.com/php/doc-en/commit/9ff8b114b8c964812eafb1e7329b760700be5745
Raw diff: https://github.com/php/doc-en/commit/9ff8b114b8c964812eafb1e7329b760700be5745.diff

document setlocale(LC_ALL, null) to retrieve current setting (#4765)

Changed paths:
  M  reference/strings/functions/setlocale.xml


Diff:

diff --git a/reference/strings/functions/setlocale.xml b/reference/strings/functions/setlocale.xml
index 4b93db2b6b9b..7f76421559c4 100644
--- a/reference/strings/functions/setlocale.xml
+++ b/reference/strings/functions/setlocale.xml
@@ -11,7 +11,7 @@
   <methodsynopsis>
    <type class="union"><type>string</type><type>false</type></type><methodname>setlocale</methodname>
    <methodparam><type>int</type><parameter>category</parameter></methodparam>
-   <methodparam><type>string</type><parameter>locales</parameter></methodparam>
+   <methodparam><type class="union"><type>string</type><type>null</type></type><parameter>locales</parameter></methodparam>
    <methodparam rep="repeat"><type>string</type><parameter>rest</parameter></methodparam>
   </methodsynopsis>
   <simpara>Alternative signature (not supported with named arguments):</simpara>
@@ -102,7 +102,7 @@
        categories, or from "LANG".
       </para>
       <para>
-       If <parameter>locales</parameter> is <literal>"0"</literal>,
+       If <parameter>locales</parameter> is &null;,
        the locale setting is not affected, only the current setting is returned.
       </para>
       <para>
@@ -184,6 +184,21 @@ echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
 $loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
 echo "Preferred locale for german on this system is '$loc_de'";
 ?>
+]]>
+    </programlisting>
+   </example>
+  </para>
+  <para>
+   <example>
+    <title><function>setlocale</function> Retrieve current setting</title>
+    <programlisting role="php" annotations="non-interactive">
+<![CDATA[
+<?php
+/* Retrieve current setting */
+$current = setlocale(LC_ALL, null);
+
+echo "Current locale '$current'";
+?>
 ]]>
     </programlisting>
    </example>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.