encodeURIComponent
See also: decodeURIComponent
Encodes special characters and URI format characters with appropriate wildcards so that a text can be transmitted securely as part of a URL.
For example, a space becomes '%20', a colon becomes '%3A', an ampersand becomes '%26', etc.
Syntax
$encodeURIComponent(text)
Parameter
Name |
Description |
text |
The text with which the URI will be securely encoded |
Return value
The coded text.
Example
Syntax |
Result |
http://anydomain.com/?p=$encodeURIComponent(This text is URI secure? Yes: Because it is encoded accordingly!) |
http://anydomain.com/?p=Dieser%20Text%20ist%20URI%20sicher%3F%20Ja%3A%20Weil%20er%20entsprechend%20kodiert%20wird! |