For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > March 2004 > #26470 [Com]: setlocale(): Difference between 0 and NULL locale









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #26470 [Com]: setlocale(): Difference between 0 and NULL locale
Mailling At Gmx Dot Co Dot Uk

2004-03-28, 10:14 pm

ID: 26470
Comment by: mailling at gmx dot co dot uk
Reported By: mail at ulrich-voelkel dot de
Status: Open
Bug Type: Documentation problem
Operating System: Gentoo Linux
PHP Version: 4.3.3
New Comment:

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))


Previous Comments:
------------------------------------------------------------------------

[2003-11-30 01:12:01] 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 )


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=26470&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com