Jan, 28 2022

Tools

URL Encode/Decode

URL encode and decode strings to make them safe to use over the Internet.

Frequently Asked Questions

URL encoding refers to changing the URL structure to be transmitted on the Internet. A URL is made from a set of limited US-ASCII characters and a few special characters such as "-," ".", "_", "~". It also consists of ASCII control characters such as horizontal tab, backspace, line feed, and vertical tab. Characters such as space, <,>, \, {, }are not allowed within URLs since they are deemed to be unsafe. URL encoding involves converting unsafe, reserved, and non-ASCII characters. It starts by converting a character to one or more bytes, then representing them by two hexadecimal digits followed by a % sign.
Decoding refers to changing the URL structure back to its original format. It changes each byte %, and all the representations are converted back to a string.
Encoding and decoding are required when you need to input a URL inside another URL parameter. This ensures that it is not broken into pieces. In addition, you can decode a URL to make sure that it is not pointing to the wrong resources. It also helps one to make sure that the URL is not pointing to a malicious resource. Web developers encode URLs to transmit data from get requests and forms safely over the internet. All unsafe characters are replaced by safe characters before submitted to the server. The browsers are responsible for encoding and decoding the URLs.

How does URL Encoding/Decoding work?

When you type a query on a browser using text, the browser converts it into a format that can be sent over the internet. It eliminates all the spaces and unsafe characters and replaces them with % followed by hexadecimal characters. For example, a + sign replaces a space, while © is represented by %C2%A9. The default character set for encoding is UTF-8 in HTML5.
Example 1
Decoded: https://example.com/test.html?do=action&time=1622692921
Encoded::https%3A%2F%2Fexample.com%2Ftest.html%3Fdo%3Daction%26time%3D1622692921

Example 2
Decoded: https://www.example.com/tutorial/urlEncoding/
Encoded: https%3A%2F%2Fwww.example.com%2Ftutorial%2FurlEncoding%2F

Example 3
Decoded: https://news.example.com/about-example-news/
Encoded: https%3A%2F%2Fnews.example.com%2Fabout-example-news%2F

How do you encode a URL in PHP?

You can encode a URL in PHP using the urlencode() function. This is an inbuilt function that is used to encode URLs. It returns a text that consists of all non-ASCII characters except for the unsafe characters, which it replaces by a % and spaces as (+) sign followed by two hexadecimal digits.
URL is the abbreviation of a uniform resource locator. It refers to an identifier that helps to locate a specific resource on the internet. The URL is made of a domain name alongside other detailed information to create a unique address that only points to a specific page. The URLs are encoded using non- ASCII characters when transferring data over the internet. This shields you from hackers trying to steal information. Encoding and decoding are done by the browser automatically. But you can also do it using tools and scripts on the internet.

Contact us, if you did not find the right answer or you have a other question?

Copyright 2018-2022 Anto Online.

Important Legal stuff:
Acceptable Use Policy | Disclaimer | Privacy Policy | Terms and Conditions.

All rights reserved. Please consider the information, scripts and instructions carefully
before using it yourself. Make sure you have ample backups! The information, scripts and
instructions are provided without warranty. Consult a professional if you are unsure.
Anto does not speak on behalf of any company and our opinions are our own.