Oihana PHP

urlencode.php

Table of Contents

Functions

urlencode()  : string
Encodes the specified URI according to RFC 3986.

Functions

urlencode()

Encodes the specified URI according to RFC 3986.

urlencode(string $uri) : string

This function applies PHP's built-in urlencode() and then decodes certain reserved characters back to their literal forms, matching RFC 3986 requirements.

Parameters
$uri : string

The URI string to encode.

Tags
example
echo urlencode("https://example.com/foo?bar=baz&qux=1");
// Outputs: https%3A%2F%2Fexample.com%2Ffoo%3Fbar%3Dbaz%26qux%3D1

echo urlencode("hello world!");
// Outputs: hello%20world!
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

The RFC 3986 compliant encoded URI string.


        
On this page

Search results