|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68410 new \NumberFormatter does not work in namespace
Submitted: 2014-11-12 12:46 UTC Modified: 2014-11-12 12:52 UTC
From: thomas at nunninger dot info Assigned:
Status: Not a bug Package: PHP Language Specification
PHP Version: 5.6.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: thomas at nunninger dot info
New email:
PHP Version: OS:


 [2014-11-12 12:46 UTC] thomas at nunninger dot info
If I have a namespace and call

    new \NumberFormatter(...)

inside the namespace I get

    Fatal error: Class 'x\NumberFormatter' not found in /home/thomas/test.php on line 7

If I add

    use \NumberFormatter;

it works.

BTW: I found this error in a class method. The reproducing script does not use classes.

Test script:

namespace x;

# use \NumberFormatter;

$nf = new \NumberFormatter( 'de_DE', NumberFormatter::PATTERN_DECIMAL );
var_dump( $nf );

Expected result:
object(NumberFormatter)#1 (0) {

Actual result:
Fatal error: Class 'x\NumberFormatter' not found in /home/thomas/test.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-12 12:52 UTC]
-Status: Open +Status: Not a bug
 [2014-11-12 12:52 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

You are getting this error because you did not fully qualify the class name when you accessed the class constant that is being passed as and argument.

The below should resolve the problem:


namespace x;

$nf = new \NumberFormatter( 'de_DE', \NumberFormatter::PATTERN_DECIMAL );
var_dump( $nf );
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 03:03:36 2021 UTC