sending arrays in _GET in php

喜夏-厌秋 提交于 2019-12-08 15:31:10

问题


php gives the ability to send arrays from the _GET.

example:

test.php?var1=abc&arr[0]=1&arr[3]=test

will output:

Array
(
    [var1] => abc
    [arr] => Array
        (
            [0] => 1
            [3] => test
        )

)

is this consider bad coding?


回答1:


No, it's usual practice. Also it's natural practice for sending selects with size greater than one.




回答2:


No.

That looks fine.

You can even do:

test.php?var1=abc&arr[]=1&arr[]=test

Which would output:

Array
(
    [var1] => abc
    [arr] => Array
        (
            [0] => 1
            [1] => test
        )

)



回答3:


Yes, it is a bad thing to do, and its also really bad for your websites SEO. It quickly gets really confusing if you put too much in the querystring. Keep it Simple!



来源:https://stackoverflow.com/questions/8327758/sending-arrays-in-get-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!