Ticks inside [ and ]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Ticks inside [ and ]

Post 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'];

<?
:?
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post 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.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

That's what I thought....

Thanks. :)
Post Reply