note 72453 added to function.constant

From: Date: Fri, 19 Jan 2007 10:13:03 +0000
Subject: note 72453 added to function.constant
Groups: php.notes 
Request: Send a blank email to php-notes+get-121915@lists.php.net to get a copy of this message
When you often write lines like <?php if(defined('FOO') && constant('FOO') === 'bar') { ... } ?> to prevent errors, you can use the following function to get the value of a constant. <?php function getconst($const) { return (defined($const)) ? constant($const) : null; } ?> Finally you can check the value with <?php if(getconst('FOO') === 'bar') { ... } ?> It's simply shorter. ---- Server IP: 212.124.37.9 Probable Submitter: 217.231.234.102 ---- Manual Page -- http://www.php.net/manual/en/function.constant.php Edit -- https://master.php.net/note/edit/72453 Del: integrated -- https://master.php.net/note/delete/72453/integrated Del: useless -- https://master.php.net/note/delete/72453/useless Del: bad code -- https://master.php.net/note/delete/72453/bad+code Del: spam -- https://master.php.net/note/delete/72453/spam Del: non-english -- https://master.php.net/note/delete/72453/non-english Del: in docs -- https://master.php.net/note/delete/72453/in+docs Del: other reasons-- https://master.php.net/note/delete/72453 Reject -- https://master.php.net/note/reject/72453 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121915) next »