note 118043 deleted from function.defined by cmb

From: Date: Tue, 15 Dec 2015 15:51:42 +0000
Subject: note 118043 deleted from function.defined by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-204371@lists.php.net to get a copy of this message
Note Submitter: fernandopsilveira at yahoo dot com dot br ---- Just like define(), defined() will check for constants exactly as specified. So, if you want to check a constant in a namespace, you will need to specify the namespace in your call to defined(), even if you're calling defined() from within a namespace. To check for a defined constant within current namespace, you can use __NAMESPACE__ magic variable: <?php namespace mytest; define('mytest\CONSTANTINE', 'value'); if (defined(__NAMESPACE__ . '\CONSTANTINE')) { print "Constant is defined and is valued " . CONSTANTINE; } ?>

« previous php.notes (#204371) next »