PHP urlencode()

urlencode - Encodes url string

Function

string urlencode ( string $str )

Parameters

$str - The url string to be encoded.

Return value

Returns a string in which all non-alphanumeric characters except dot (.), dash (-), underscore (_) have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs.

Example

<?php
$str = 'url encoder';
echo "http://example.com/?param=" . urlencode( $str );
?>

Output

http://example.com/?param=url+encoder

Github

See also: