note 45946 added to function.define
| From: | fontajos at phpeppershop dot com | Date: | Fri, 24 Sep 2004 10:12:55 +0000 |
| Subject: | note 45946 added to function.define | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77302@lists.php.net to get a copy of this message | ||
Justin Frenchs comment on scope definition of a constant are not true, his example ommited calling
the function, which defines the PET_NAME constant, that's why his conclusion is wrong, that
constants are only visible in the scope of a function / class. Constants are like superglobals.
Test:
--------
function test() {
define('PET_NAME','fluffy');
}
test();
define('PET_TYPE','cat');
echo PET_NAME.'is a '.PET_TYPE;
Will echo "fluffy is a cat", not "PET_NAME is a cat".
maybe you simply remove the misleading posting.
----
Manual Page -- http://www.php.net/manual/en/function.define.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45946
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45946&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45946&report=yes
Search -- http://master.php.net/manage/user-notes.php