url_encode_component()

The function converts characters of the input URL into a format that can be transmitted over the internet. Differs from url_encode by encoding spaces as '%20' and not as '+'.

For more information about URL encoding and decoding, see Percent-encoding.

Syntax

url_encode_component(url)

Learn more about syntax conventions.

Parameters

Name Type Required Description
url string ✔️ The URL to encode.

Returns

URL (string) converted into a format that can be transmitted over the Internet.

Example

let url = @'https://www.bing.com/hello world/';
print original = url, encoded = url_encode_component(url)

Output

original encoded
https://www.bing.com/hello world/ https%3a%2f%2fwww.bing.com%2fhello%20world