note 90282 added to function.define
| From: | danbettles at yahoo dot co dot uk | Date: | Tue, 14 Apr 2009 18:56:37 +0000 |
| Subject: | note 90282 added to function.define | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153212@lists.php.net to get a copy of this message | ||
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: 87.124.35.190
Probable Submitter: 78.144.206.31
----
Manual Page -- http://www.php.net/manual/en/function.define.php
Edit -- https://master.php.net/note/edit/90282
Del: integrated -- https://master.php.net/note/delete/90282/integrated
Del: useless -- https://master.php.net/note/delete/90282/useless
Del: bad code -- https://master.php.net/note/delete/90282/bad+code
Del: spam -- https://master.php.net/note/delete/90282/spam
Del: non-english -- https://master.php.net/note/delete/90282/non-english
Del: in docs -- https://master.php.net/note/delete/90282/in+docs
Del: other reasons-- https://master.php.net/note/delete/90282
Reject -- https://master.php.net/note/reject/90282
Search -- https://master.php.net/manage/user-notes.php