Re: "Use of undefined constant" error

From: Date: Tue, 17 Dec 2002 10:52:03 +0000
Subject: Re: "Use of undefined constant" error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-128530@lists.php.net to get a copy of this message
you've got error reporting set pretty high to get that. The correct way to reference an array element in this case is $_GET["id"], if you do $_GET[id] you are telling PHP to look for a constant called id. If it doesn't find one then it assumes you meant "id" onstead of id and proceeds accordingly. Thats why you can get away with not using the quote marks (as long as there's no white space in the string). On a live site (and, I'd have thought, most default set-ups) you'd expect error reporting to be set all off and you'd never see the message. Tim Ward http://www.chessish.com mailto:timward@chessish.com ----- Original Message ----- From: fragmonster <frederic@argyro.net> To: <php-general@lists.php.net> Sent: Tuesday, December 17, 2002 10:49 AM Subject: [PHP] "Use of undefined constant" error > Hello, > I've got a strange pb. Here's my code > > <? > if(isset($_GET[id])){ > do something... > else > do something else > } > ?> > > When I call myfile.php or myfile.php?id=1 I've got an error message > "Notice: Use of undefined constant id - assumed 'id' in ..." > > Please help > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#128530) next »