note 116745 added to function.define

From: Date: Sun, 22 Feb 2015 03:11:47 +0000
Subject: note 116745 added to function.define
Groups: php.notes 
Request: Send a blank email to php-notes+get-201780@lists.php.net to get a copy of this message
Be aware that if "Notice"-level error reporting is turned off, then trying to use a constant as a variable will result in it being interpreted as a string, if it has not been defined. I was working on a program which included a config file which contained: <?php define('ENABLE_UPLOADS', true); ?> Since I wanted to remove the ability for uploads, I changed the file to read: <?php //define('ENABLE_UPLOADS', true); ?> However, to my surprise, the program was still allowing uploads. Digging deeper into the code, I discovered this: <?php if ( ENABLE_UPLOADS ): ?> Since 'ENABLE_UPLOADS' was not defined as a constant, PHP was interpreting its use as a string constant, which of course evaluates as True. ---- Server IP: 72.52.91.14 Probable Submitter: 50.129.95.37 ---- Manual Page -- http://php.net/manual/en/function.define.php Edit -- https://master.php.net/note/edit/116745 Del: integrated -- https://master.php.net/note/delete/116745/integrated Del: useless -- https://master.php.net/note/delete/116745/useless Del: bad code -- https://master.php.net/note/delete/116745/bad+code Del: spam -- https://master.php.net/note/delete/116745/spam Del: non-english -- https://master.php.net/note/delete/116745/non-english Del: in docs -- https://master.php.net/note/delete/116745/in+docs Del: other reasons-- https://master.php.net/note/delete/116745 Reject -- https://master.php.net/note/reject/116745 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201780) next »