sending arrays in _GET in php

2019-06-15 13:31发布

问题:

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!



标签: php arrays get