Bug #16147 Updated: error "Warning: Use of undefined constant"

From: Date: Tue, 26 Mar 2002 01:57:50 +0000
Subject: Bug #16147 Updated: error "Warning: Use of undefined constant"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-3339@lists.php.net to get a copy of this message
ID: 16147 Updated by: philip@php.net Reported By: leo.sten@telia.com Status: Bogus Bug Type: Scripting Engine problem Operating System: win 2000 PHP Version: 4.1.2 New Comment: Just a fyi, with: print $array[foo]; PHP looks for a constant named foo first, if it does not exist then it'll shout an error of level E_NOTICE and then look for the key foo (which is what you wanted) ... error_reporting can be set about anywhere, including php.ini, .htaccess and the error_reporting() function. And some code: define('a', 'b'); $arr = array('a' => 'apple', 'b' => 'banana'); print $arr[a]; // banana print $arr['a']; // apple Moral of the story is you should always surround your array keys with quotes! ;) Previous Comments: ------------------------------------------------------------------------ [2002-03-18 11:41:48] jtate@php.net Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". ------------------------------------------------------------------------ [2002-03-18 11:39:17] leo.sten@telia.com Hello! I have just installed php4 on my server, I'm running IIS on windows 2000. When I run some scripts that I know work on other servers I get the error: "Warning: Use of undefined constant" and then the constant name etc. Best Regards/ Leo Sten ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16147&edit=1

« previous php.bugs (#3339) next »