Square brackets in HTML form arrays. Just conventional or with a meaning?

前端 未结 2 1943
再見小時候
再見小時候 2021-01-05 00:13

I frequently see, in particular in the PHP world, the following writing if you want to create a FORM array.




        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 00:41

    They address a limitation of PHP, which doesn't generate an array automatically if multiple values with the same name are submitted, for example from a set of checkboxes or a multiple select. (IIRC it only returns the last value.)

    Personally I've always thought it to be a pretty shoddy workaround. Even Classic ASP could cope with that without requiring client-side additions to markup. The server-side platform has no business imposing markup requirements on the client in this way.

提交回复
热议问题