url_encode()

The function converts characters of the input URL into a format that can be transmitted over the internet. Differs from url_encode_component by encoding spaces as '+' and not as '%20' (see application/x-www-form-urlencoded here).

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

Syntax

url_encode(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.

Examples

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

Output

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