note 118044 added to function.define

From: Date: Wed, 23 Sep 2015 17:05:36 +0000
Subject: note 118044 added to function.define
Groups: php.notes 
Request: Send a blank email to php-notes+get-203843@lists.php.net to get a copy of this message
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; } ?> ---- Server IP: 187.73.33.55 Probable Submitter: 200.175.79.179 ---- Manual Page -- http://php.net/manual/en/function.define.php Edit -- https://master.php.net/note/edit/118044 Del: integrated -- https://master.php.net/note/delete/118044/integrated Del: useless -- https://master.php.net/note/delete/118044/useless Del: bad code -- https://master.php.net/note/delete/118044/bad+code Del: spam -- https://master.php.net/note/delete/118044/spam Del: non-english -- https://master.php.net/note/delete/118044/non-english Del: in docs -- https://master.php.net/note/delete/118044/in+docs Del: other reasons-- https://master.php.net/note/delete/118044 Reject -- https://master.php.net/note/reject/118044 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203843) next »