utf8_uri_encode()
Encode the Unicode values to be used in the URI.
No Hooks.
Return
String
. String with Unicode encoded for URI.
Usage
utf8_uri_encode( $utf8_string, $length, $encode_ascii_characters );
- $utf8_string(string) (required)
- String to encode.
- $length(int)
- Max length of the string
- $encode_ascii_characters(true|false)
- Whether to encode ascii characters such as < " '
Default: false
Examples
#1 Create a correct URI for non-latin characters:
$utf8_string = "http://example.com/ссылка-на_istochnik"; echo utf8_uri_encode( $utf8_string ); // вернет: // http://example.com/%d1%81%d1%81%d1%8b%d0%bb%d0%ba%d0%b0-%d0%bd%d0%b0_istochnik
Changelog
Since 1.5.0 | Introduced. |
Since 5.8.3 | Added the encode_ascii_characters parameter. |