简体   繁体   English

PHP中的URL编码

[英]URL encoding in PHP

I am trying to see if url encoding of get parameters while submitting a form is possible. 我试图查看提交表单时获取参数的url编码是否可行。 I have seen a few resources where url encoding is being is used where the URLs are built dynamically 我已经看到了一些使用URL编码的资源,这些URL是动态构建的

ex: www.google.com?query=urlencode($query)

But how do I apply the function url encode if I am using a form and a submit button. 但是,如果我使用表单和提交按钮,该如何应用函数url编码。

<html>
        <body>
                <form action="send.php" method="get">
                <input type="input" name="method" value="" />
                <input type="submit" name="submit" value="submit"/>
                </form>
        </body>
</html>

The browser will urlencode them for you. 浏览器将为您使用urlencode。 Go to google and search for "&", and you'll see "q=%26" in the URL. 转到Google并搜索“&”,然后您会在URL中看到“ q =%26”。

This is done by browser if you ask it to do, consider using enctype="application/x-www-form-urlencoded" 如果您要求浏览器完成此操作,请考虑使用enctype =“ application / x-www-form-urlencoded”

<html>
        <body>
                <form action="send.php" method="get" enctype="application/x-www-form-urlencoded">
                <input type="input" name="method" value="" />
                <input type="submit" name="submit" value="submit"/>
                </form>
        </body>
</html>

note that it is done by default in most modern browsers if you don't even specify enctype. 请注意,如果您甚至不指定enctype,大多数现代浏览器默认都会完成此操作。

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

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