sending arrays in _GET in php

2019-06-15 13:14发布

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?

标签: php arrays get
3条回答
beautiful°
2楼-- · 2019-06-15 13:37

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!

查看更多
放荡不羁爱自由
3楼-- · 2019-06-15 13:41

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
        )

)
查看更多
啃猪蹄的小仙女
4楼-- · 2019-06-15 13:45

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

查看更多
登录 后发表回答