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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux