Home > php教程 > PHP源码 > Build query string

Build query string

WBOY
Release: 2016-08-18 08:57:54
Original
1332 people have browsed it
跳至 [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&amp;color=red&amp;favorite_punctuation=%23


~                                                                                                                                                                                                           
~                    
Copy after login
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