note 109257 added to function.defined
| From: | michael at squiloople dot com | Date: | Sat, 30 Jun 2012 12:23:25 +0000 |
| Subject: | note 109257 added to function.defined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188977@lists.php.net to get a copy of this message | ||
It should be noted that defined() does not work on magic constants; it will always* return
bool(false). However, (re-)defining a magic constant will silently fail. As such the common
work-around for defining the __DIR__ magic constant, for example, is unnecessary; it is simply
enough to use the following, which will for all intents and purposes be ignored if using PHP 5.3+:
<?php
define('__DIR__', dirname('__FILE__'));
?>
*Using defined() after re-defining a magic constant (which will fail silently) will return
bool(true) -- although its value will be the default and not to whatever it was manually set.
----
Server IP: 69.147.83.197
Probable Submitter: 159.15.67.78
----
Manual Page -- http://www.php.net/manual/en/function.defined.php
Edit -- https://master.php.net/note/edit/109257
Del: integrated -- https://master.php.net/note/delete/109257/integrated
Del: useless -- https://master.php.net/note/delete/109257/useless
Del: bad code -- https://master.php.net/note/delete/109257/bad+code
Del: spam -- https://master.php.net/note/delete/109257/spam
Del: non-english -- https://master.php.net/note/delete/109257/non-english
Del: in docs -- https://master.php.net/note/delete/109257/in+docs
Del: other reasons-- https://master.php.net/note/delete/109257
Reject -- https://master.php.net/note/reject/109257
Search -- https://master.php.net/manage/user-notes.php