Page 1 of 1

Ticks inside [ and ]

Posted: Tue Mar 30, 2004 7:10 pm
by Steveo31
According to http://www.php.net/manual/en/language.t ... rray.donts , one cannot use $foo[bar]. Does this also apply to POST and GET variables such as

Code: Select all

<?php

$name = $_POST[name];

?>
I thought it had to be

Code: Select all

<?php

$name = $_POST['name'];

<?
:?

Posted: Tue Mar 30, 2004 7:12 pm
by andre_c
It does because they could be constants, if you don't put quotes or php might in the future include a predefined constant with that name. It applies to all associative arrays.

Posted: Tue Mar 30, 2004 7:13 pm
by Steveo31
That's what I thought....

Thanks. :)