You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

urlencode()

Usage

urlencode(string)

Description
Encodes the given string for use in an URL, replacing invalid characters with their valid URL equivalent.

Example

${urlencode('This is a test')}

results in

This+is+a+test

Search results for "urlencode()"

urlencode()

Encodes the given string for use in an URL, replacing invalid characters with their valid URL equivalent.

urlencode(string)

formurlencode()

Encodes the given object for use in an URL, replacing invalid characters with their valid URL equivalent and joining the key/value pairs with an ampersand.

formurlencode(object)

Request Parameters

In the example above, the space character is encoded as “% 20”. URL encoding is normally done by the HTTP client, so you don’t have to do it manually. There are however some situations where manual URL encoding is necessary, for example if you build your own URL string in a script. For that purpose Structr provides the urlencode() built-in function. In a Javascript context, the global functions encodeURI() and encodeURIComponent() exist.