← All built-ins / urlencode()

urlencode()

urlencode(string $s): string

Parameters

NameTypeDescription
$sstringtext for a query string

Return value

Encoded text: space becomes +, reserved characters become %XX.

Example

echo urlencode("holy php & more");
holy+php+%26+more

See also

urldecode()http_build_query()