Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Naming form elements "foo[]": Quirk of Feature?

Status
Not open for further replies.

sleipnir214

Programmer
May 6, 2002
15,350
US
In PHP if I have a group of checkboxes and name them all "foo[]", PHP will make the checked values available in a single array named $_POST["foo"].

I want to know whether this is a quirk of the language which might be eliminated one day, or a documented feature which will be kept in future versions of PHP.

Can anyone provide a link to a web document which says one way or the other?
 
Your links are good, but that's not what I'm looking for. "Close, but no star."

I'm looking for a canonical reference from the PHP or Zend websites or elsewhere that states for a fact this is a feature which will be provided in future versions of PHP.

A lot of us would be up a creek without the proverbial paddle if we were to keep using it, then discover to our horror that a new version of PHP removes that facility.
 
I haven't found anything "official" saying that it will or won't be there, but it's been like that for so long and as you could see, everyone was talking as if it were a feature, that I think it's safe to assume it will be there for a while.

Rick If I have helped you just click the first link below to let me know :)
 
$HTTP_[POST|GET|SERVER]_VARS have been there a while, too. They're deprecated, now.

I found one link: the PHP site itself (not the user-contributed comments) recommends the practice here:
So I am somewhat reassured. An implicit declaration that it is a feature is better than nothing.
 
Well, my opinion goes to don't change anything cause php project can fail is, for example they remove the $HTTP_*_VARS. There are too many applications using it and there can be a lot of trouble if a new version appears without it. For example, i will not upgrade php to that new version cause all my websites are going to have failures.

If you start programing with the $_* arrays, be sure that they are not going to be changed.
Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Yeah, it's good to know that a feature on which your code depends will always be ther (hence my question that began this thread). But I am willing to accept removal of kruft from a system if it means that the system will be improved by it. Provided that the removal is announced with appropriate fanfare, with sufficient advanced notice, and with sage advice on how to work around the removal.

PHP is saying now in the online manual ( that the $HTTP_*_VARS arrays are deprecated in favor of $_* superglobal arrays. From that, I infer that the $HTTP_*_VARS arrays will be removed from the language eventually.

Once Zend or PHP or whoever removes $HTTP_*_VARS from the language, the workaround should be fairly painless, though. There is for the most part a one-to-one mapping, for example, between $HTTP_POST_VARS and $_POST. And I guess then the removal of the unnecessary "global" statements, too, would be nice.
 
Well,

but even as deprecated, i assume that zend will not fall in that error, because it's a ver sensible question. Too many applications in PHP uses the HTTP_*_VARS. Well, it's a thing to question in the future. But i assume that they will not remove that vars in the next 3 or 4 years.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top