ID: 49046 User updated by: simon at stienen dot name Reported By: simon at stienen dot name -Status: Feedback +Status: Open Bug Type: Scripting Engine problem Operating System: FreeBSD PHP Version: 5.3SVN-2009-07-24 (SVN) New Comment:
Whyever this is necessary: <?php namespace Foo; const Bar = "Blob"; namespace \Bar; function x() { echo __NAMESPACE__; } x(); ?> ... happy now? Previous Comments: ------------------------------------------------------------------------ [2009-07-24 13:12:27] j...@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2009-07-24 11:26:58] simon at stienen dot name Description: ------------ So much wrong here ... The initial intention was to get back into global namespace using the "namespace X;" syntax. (Why isn't this possible? Neither as namespace; namespace \; ... not even namespace \\;) Curiously, "namespace \" expected the name of a constant. Even more curiously, "namespace \foo" is looking for the constant "foo" in the *current* namespace. If the constant exists, the namespace directive is simply ignored. If it does not, the script dies with a fatal error. Reproduce code: --------------- namespace Foo; const Bar = "Blob"; namespace \Bar; function x() { echo __NAMESPACE__; } x(); Expected result: ---------------- Pretty much everything else than the actual result ... but at least "Bar" or "Blob" Actual result: -------------- Foo ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49046&edit=1