note 90283 added to language.namespaces.definition
| From: | danbettles at yahoo dot co dot uk | Date: | Tue, 14 Apr 2009 19:02:21 +0000 |
| Subject: | note 90283 added to language.namespaces.definition | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153213@lists.php.net to get a copy of this message | ||
Regarding constants defined with define() inside namespaces...
define() will define constants exactly as specified. So, if you want to define a constant in a
namespace, you will need to specify the namespace in your call to define(), even if you're
calling define() from within a namespace. The following examples will make it clear.
The following code will define the constant "MESSAGE" in the global namespace (i.e.
"\MESSAGE").
<?php
namespace test;
define('MESSAGE', 'Hello world!');
?>
The following code will define two constants in the "test" namespace.
<?php
namespace test;
define('test\HELLO', 'Hello world!');
define(__NAMESPACE__ . '\GOODBYE', 'Goodbye cruel world!');
?>
----
Server IP: 92.48.74.199
Probable Submitter: 78.144.206.31
----
Manual Page -- http://www.php.net/manual/en/language.namespaces.definition.php
Edit -- https://master.php.net/note/edit/90283
Del: integrated -- https://master.php.net/note/delete/90283/integrated
Del: useless -- https://master.php.net/note/delete/90283/useless
Del: bad code -- https://master.php.net/note/delete/90283/bad+code
Del: spam -- https://master.php.net/note/delete/90283/spam
Del: non-english -- https://master.php.net/note/delete/90283/non-english
Del: in docs -- https://master.php.net/note/delete/90283/in+docs
Del: other reasons-- https://master.php.net/note/delete/90283
Reject -- https://master.php.net/note/reject/90283
Search -- https://master.php.net/manage/user-notes.php