首页  >  文章  >  php教程  >  构建查询字符串

构建查询字符串

WBOY
WBOY原创
2016-08-18 08:57:541258浏览
跳至 [1] [全屏预览]
  <?php
  /**
   * 构建查询字符串
   */
   
  $vars = array('name' => 'this is a name',
                'color' => 'red',
                'favorite_punctuation' => '#');
  $query_str = http_build_query($vars);
  
  $url = '/test/test.php?' . $query_str;
  echo $url."\n";
  
  $url = '/test/test.php?' . htmlentities($query_str);
  echo $url."\n";

输出结果:
/test/test.php?name=this+is+a+name&color=red&favorite_punctuation=%23
/test/test.php?name=this+is+a+name&color=red&favorite_punctuation=%23


~                                                                                                                                                                                                           
~                    
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn