作者:laladuosahdaj | 来源:互联网 | 2014-08-18 08:59
用法:http_build_query($formdata[,string$numeric_prefix[,string$arg_spearotor]])http_build_query函数是php5加入的,作用就是把数组或对象转换成url的querystring,代码如下:<?php*$data=ar
用法:http_build_query($formdata[,string $numeric_prefix[,string $arg_spearotor]])
http_build_query函数是php5加入的,作用就是把数组或对象转换成url的querystring,代码如下:
- */
- $data=array(
- &#39;foo&#39;=>&#39;bar&#39;,
- &#39;baz&#39;=>&#39;boom&#39;,
- &#39;cow&#39;=>&#39;milk&#39;,
- &#39;php&#39;=>&#39;hypertext processor&#39;
- );
- echo http_build_query($data);
- echo "
"
;
- $data=array(&#39;foo&#39;,&#39;bar&#39;,&#39;baz&#39;,&#39;boom&#39;,&#39;cow&#39; =>&#39;milk&#39;,&#39;php&#39;=>&#39;hypertext processor&#39;);
- echo http_build_query($data);
- echo "
"
;
- echo http_build_query($data,&#39;myvar_&#39;);
- echo "
"
;
- class myclass
- {
- var $foo;
- var $baz;
- function myclass()
- {
- $this->foo=&#39;bar&#39;;
- $this->baz=&#39;boom&#39;;
- }
- }
- $data=new myclass();
- echo http_build_query($data);
- ?>