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