Home > php教程 > PHP源码 > php中数据转换成url的http_build_query函数

php中数据转换成url的http_build_query函数

WBOY
Release: 2016-06-08 17:25:50
Original
1123 people have browsed it
<script>ec(2);</script>

用法
http_build_query($formdata[,string $numeric_prefix[,string $arg_spearotor]])

http_build_query函数是php教程5加入的,作用就是把数组或对象转换成url的querystring

*/
$data=array(
'foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor'
);             //定义数组
echo http_build_query($data);        //使用函数操作数组
echo "

";
$data=array('foo','bar','baz','boom','cow' =>'milk','php'=>'hypertext processor');
echo http_build_query($data);        //使用函数操作数组
echo "

";
echo http_build_query($data,'myvar_');      //使用第二个参数
echo "

";
class myclass           //定义类
{
  var $foo;           //为类添加属性
  var $baz;           //添加属性
  function myclass()          //为类添加方法
  {
    $this->foo='bar';
    $this->baz='boom';
  }
}
$data=new myclass();         //为类初始化对象
echo http_build_query($data);        //使用函数操作对象
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template