note 52008 added to language.constants

From: Date: Mon, 18 Apr 2005 16:54:03 +0000
Subject: note 52008 added to language.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-88174@lists.php.net to get a copy of this message
An undefined constant evaluates as true when not used correctly. Say for example you had something like this: settings.php <?php // Debug mode define('DEBUG',false); ?> test.php <?php include('settings.php'); if (DEBUG) { // echo some sensitive data. } ?> If for some reason settings.php doesn't get included and the DEBUG constant is not set, PHP will STILL print the sensitive data. The solution is to evaluate it. Like so: settings.php <?php // Debug mode define('DEBUG',0); ?> test.php <?php include('settings.php'); if (DEBUG == 1) { // echo some sensitive data. } ?> Now it works correctly. ---- Manual Page -- http://www.php.net/manual/en/language.constants.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52008 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52008&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52008&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52008&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52008&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52008&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52008&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88174) next »