简体   繁体   English

如何避免HTML / php网址编码&?

[英]How to avoid HTML/php url encoding &?

I need help with url encoding. 我需要有关网址编码的帮助。

I want my site to look like this: 我希望我的网站看起来像这样:

http://127.0.0.1/?search=&s=searchItem

but instead, it looks like this: 但是,它看起来像这样:

http://127.0.0.1/?search%3D%26s=searchItem

This is the HTML code: 这是HTML代码:

<div class="navigation">
<form class="example" action="<?php echo home_url( '/' ); ?>" method="get">
  <input type="text" placeholder="Search" name="search=&s">
  <button type="submit"><i class="searching"></i></button>
</form> 
</div>

worry not. 不用担心

this is the url encoded version of your original url. 这是原始网址的网址编码版本。 that's the way your browser interprets it. 这就是您的浏览器解释它的方式。 Usualy php will convert it automaticaly, and if it does not simply use urldecode method and you will get it right. 通常,php会自动将其转换,如果不简单地使用urldecode方法,则您会正确地进行转换。

Still, you dont have to manipulate the query string yourself, php handles it for you and puts it oon the $_GET variable for you, however, try to use a filter before manipulating it with php's filter_var function. 不过,您不必自己操纵查询字符串,php会为您处理查询字符串并将其放在$ _GET变量上,但是,在使用php的filter_var函数操作它之前,请尝试使用过滤器。

<div class="navigation">
   <form class="example" action="<?php echo home_url('/'); ?>" 
method="get">
       <input type="hidden" placeholder="Search" name="search">
       <input type="text" placeholder="Search" name="s">
       <button type="submit"><i class="searching"></i></button>
   </form> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM