欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

构建查询字符串

程序员文章站 2022-04-15 21:33:29
...
跳至 [1] [全屏预览]
   '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


~                                                                                                                                                                                                           
~                    
相关标签: 构建查询字符串