#50038 [Opn->Bgs]: PHP doesn't like it when a namespace starts with a number for example 12eggs

From: Date: Fri, 30 Oct 2009 16:03:29 +0000
Subject: #50038 [Opn->Bgs]: PHP doesn't like it when a namespace starts with a number for example 12eggs
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3027@lists.php.net to get a copy of this message
ID: 50038 Updated by: johannes@php.net Reported By: me at gerryevans dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: CentOS PHP Version: 5.3.0 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Identifiers have to start with a letter. The same rule applies for class names, function names, variables, constants, ... Previous Comments: ------------------------------------------------------------------------ [2009-10-30 12:39:09] me at gerryevans dot com Yep, that make sense. You should include in the PHP docs that the naming rules apply to namespaces, as at the moment their no mention of it. Out of interest, is there any reason why the naming rules doesn't allow the names to start with numbers? ------------------------------------------------------------------------ [2009-10-30 12:08:30] colder@php.net namespaces' names follow the same rule as classes/functions' names, which can't start by numbers either. ------------------------------------------------------------------------ [2009-10-30 10:49:38] me at gerryevans dot com I have tested this error on a CentOS server running Apache 2 + PHP 5.3 and Lighttpd + PHP 5.3. The php.ini both times was a php.ini-production with the only change "expose_php" to Off. ------------------------------------------------------------------------ [2009-10-30 10:35:03] me at gerryevans dot com Description: ------------ PHP doesn't like it when a namespace starts with a number for example a namespace 12eggs will get a parse error ("syntax error, unexpected T_LNUMBER, expecting T_STRING or T_NS_SEPARATOR or '{'"). Reproduce code: --------------- <?php namespace 12eggs; echo __NAMESPACE__; ?> Expected result: ---------------- 12eggs Actual result: -------------- Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_NS_SEPARATOR or '{' in FILE on line 3 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50038&edit=1

« previous php.doc.bugs (#3027) next »