Re[2]: [PHP] Parse error: parse error, expecting `']'' in

From: Date: Thu, 02 Dec 2004 13:39:49 +0000
Subject: Re[2]: [PHP] Parse error: parse error, expecting `']'' in
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-203337@lists.php.net to get a copy of this message
Hello Robert, Thursday, December 2, 2004, 1:21:33 PM, you wrote: RS> Unfortunately?? I knew exactly where the code was breaking (the RS> lines I posted) since before I added those lines of code the RS> script worked without any problems. But what I don't understand is RS> why sometimes '$_POST[variable]' works and why sometimes it will RS> only work when it is '$_POST['variable']' . It should always be the second way ($_POST['var']), although the first way *will* work most of the time it was cause PHP to first check to see if 'var' is a defined constant, and then a variable. If it is a constant, it will substitute that value instead which could cause no end of problems. When called with: test.php?a=a&b=b the following should print out ab. Remove the quotes from $_GET[a] and you'll see the difference. <?php define("a", "b"); echo $_GET['a']; echo $_GET['b']; ?> Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services "I am not young enough to know everything." - Oscar Wilde

« previous php.general (#203337) next »