note 113130 added to language.constants.predefined

From: Date: Tue, 03 Sep 2013 12:11:49 +0000
Subject: note 113130 added to language.constants.predefined
Groups: php.notes 
Request: Send a blank email to php-notes+get-196150@lists.php.net to get a copy of this message
Magic constants can not be tested with defined($name) <?php if(!defined(__DIR__)){ //will not work } ?> when __DIR__ is not defined and you use it anyway php assumes you meant '__DIR__' and throws a notice. because of this assumption we can do: <?php if(@__DIR__ == '__DIR__'){ echo 'magic __DIR__ constant NOT defined'; //insert this code where needed, remember that because they are MAGIC constants defining __DIR__ is completely useless }echo{ echo 'magic __DIR__ constant IS defined'; } ?> ---- Server IP: 83.137.20.135 Probable Submitter: 89.20.91.23 ---- Manual Page -- http://php.net/manual/en/language.constants.predefined.php Edit -- https://master.php.net/note/edit/113130 Del: integrated -- https://master.php.net/note/delete/113130/integrated Del: useless -- https://master.php.net/note/delete/113130/useless Del: bad code -- https://master.php.net/note/delete/113130/bad+code Del: spam -- https://master.php.net/note/delete/113130/spam Del: non-english -- https://master.php.net/note/delete/113130/non-english Del: in docs -- https://master.php.net/note/delete/113130/in+docs Del: other reasons-- https://master.php.net/note/delete/113130 Reject -- https://master.php.net/note/reject/113130 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196150) next »