php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16147 error "Warning: Use of undefined constant"
Submitted: 2002-03-18 11:39 UTC Modified: 2002-03-25 20:57 UTC
From: leo dot sten at telia dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.1.2 OS: win 2000
Private report: No CVE-ID: None
 [2002-03-18 11:39 UTC] leo dot sten at telia dot 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-18 11:41 UTC] 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-25 20:57 UTC] philip@php.net
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! ;)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 21:01:26 2024 UTC