php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26470 setlocale(): Difference between 0 and NULL locale
Submitted: 2003-11-30 01:12 UTC Modified: 2004-09-16 16:14 UTC
Votes:4
Avg. Score:3.0 ± 1.6
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: mail at ulrich-voelkel dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.3 OS: Gentoo Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mail at ulrich-voelkel dot de
New email:
PHP Version: OS:

 

 [2003-11-30 01:12 UTC] mail at ulrich-voelkel dot de
Description:
------------
Hi there!

On http://de.php.net/manual/en/function.setlocale.php
the description of "string setlocale ( mixed category, array locale)" says
"If locale is NULL or "0", the locale setting is not affected, only the current setting is returned."

On my Gentoo Box I figured out that giving "NULL" behaves different to "0".
After setting the LC_ALL from the C locale to "de_DE" (or anything else) "setlocale(LC_ALL, 0)" worked correctly and returnd all locale Variables with their values set to "de_DE" (as expected). Refering to the Documentation I expected the same result from "setlocale(LC_ALL, NULL) but I didn`t get it.
It just set all locale vaiables back to the default C Value.

Thanks for your efforts,
Uli

Reproduce code:
---------------
<?php                                                                                
echo "Default locale: " . setlocale(LC_ALL, 0) . "<br />";
setlocale(LC_ALL, "de_DE");                                                                                
$locales = explode(";", setlocale(LC_ALL, NULL));                                                                                
echo "New locale: ";
print_r($locales);                                                                                
?>

Expected result:
----------------
Default locale: C
New locale: Array ( [0] => LC_CTYPE=de_DE [1] => LC_NUMERIC=C [2] => LC_TIME=de_DE [3] => LC_COLLATE=de_DE [4] => LC_MONETARY=de_DE [5] => LC_MESSAGES=de_DE [6] => LC_PAPER=de_DE [7] => LC_NAME=de_DE [8] => LC_ADDRESS=de_DE [9] => LC_TELEPHONE=de_DE [10] => LC_MEASUREMENT=de_DE [11] => LC_IDENTIFICATION=de_DE )

Actual result:
--------------
Default locale: C
New locale: Array ( [0] => C )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-28 11:16 UTC] mailling at gmx dot co dot uk
I think that you get with null the default locale, based on the original value when you start php (changing with putenv the LANG or the LANGUAGE variable doesn't change the behavior or setlocale(LC_ALL, null))
 [2004-09-16 16:14 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Null is equivalent to '', not '0'.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 13:00:01 2025 UTC