Search code examples
phphtmlgeturlencodeurldecode

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 built 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>

Solution

  • The browser will urlencode them for you. Go to google and search for "&", and you'll see "q=%26" in the URL.