http_build_query()函数的作用是使用给出的关联(或下标)数组生成一个经过 URL-encode 的请求字符串。
用于模拟http请求的,把得到的数据data通过函数URL-encode,一般是用在回调。
NULL 的值将会被会略
<?php
$arr = array('test' => null, 'test2' => 1);
// test2=1
echo http_build_query($arr);
来源: https://www.php.net/manual/zh/function.http-build-query.php#60523
True 和 False 将会被转换成数字
<?php
$a = [teste1= true,teste2=false];
// teste1=1&teste2=0
echo http_build_query($a)
来源: https://www.php.net/manual/zh/function.http-build-query.php#122232
空的数组不会出现在结果中
<?php
$post_data = array('name'=>'miller', 'address'=>array('address_lines'=>array()), 'age'=>23);
// name=miller&age=23
echo http_build_query($post_data);
来源: https://www.php.net/manual/zh/function.http-build-query.php#109466