http_build_query ignores the key if the value is an empty array. How is this not a bug?

前端 未结 5 1151
死守一世寂寞
死守一世寂寞 2021-02-13 13:16

I ran into a problem today where I was passing a key with the value set to an empty array to http_build_query(). E.g.:

$args = array(\"foo\", \"bar\         


        
5条回答
  •  日久生厌
    2021-02-13 13:20

    Can somebody explain to me why this is not a bug?

    Technically, I don't think it should be labeled a bug. Rather, it's just how they designed the function to behave, whether others disagree with that decision or not.

    Your API could just check with if (empty($_POST['2']))

提交回复
热议问题