php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70585 empty $locale is treated as default locale
Submitted: 2015-09-25 16:33 UTC Modified: 2021-08-13 15:24 UTC
From: b8kich+php at gmail dot com Assigned:
Status: Verified Package: intl (PECL)
PHP Version: 5.5.29 OS: GNU/Linux 2.6.32-358.18.1.el6.x8
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-09-25 16:33 UTC] b8kich+php at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/locale.getregion
---

Return Values
The region subtag for the locale or NULL if not present

Test script:
---------------
$ php -r "echo Locale::getRegion(null);"
US

$ php -v
PHP 5.5.29 (cli) (built: Sep  9 2015 01:34:19


Expected result:
----------------
'' (null)

Actual result:
--------------
US

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-13 15:24 UTC] cmb@php.net
-Summary: getRegion should return null instead of defaulting to 'US' +Summary: empty $locale is treated as default locale -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -Package: *Languages/Translation +Package: intl
 [2021-08-13 15:24 UTC] cmb@php.net
If an empty string is passed as $locale to any of the Locale
methods or their procedural counterparts, it acts as the default
locale[1].  The documentations mentions the behavior of an empty
string[2], but erroneously states that this would act as the root
locale.

[1] <https://github.com/php/php-src/blob/php-7.4.21/ext/intl/locale/locale_methods.c#L407-L410>
[2] <https://www.php.net/manual/en/class.locale.php>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Sep 25 10:03:37 2021 UTC