From:             mail at ulrich-voelkel dot de
Operating system: Gentoo Linux
PHP version:      4.3.3
PHP Bug Type:     Documentation problem
Bug description:  setlocale(): Difference between 0 and NULL locale

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 )

-- 
Edit bug report at http://bugs.php.net/?id=26470&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26470&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26470&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26470&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26470&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26470&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26470&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26470&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26470&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26470&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26470&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26470&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26470&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26470&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26470&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26470&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26470&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26470&r=float

Reply via email to