URL encoding in PHP
I am trying to see if URL encoding of GET parameters while submitting a form is possible. I have seen a few resources where URL encoding is being is used where the URLs are buil开发者_开发技巧t dynamically
Example: www.google.com?query=urlencode($query)
But how do I apply the function urlencode() if I am using a form and a submit button?
<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. Go to google and search for "&", and you'll see "q=%26" in the URL.
This is done by the browser if you ask it to do it. Consider using 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.
精彩评论