rawurlencode
Encoding URLs according to RFC 3986
Function name: rawurlencode()
Applicable versions: PHP 4, PHP 5, PHP 7
Usage: rawurlencode(string $str): string
Function description: The rawurlencode() function URL encodes the string, converts special characters into an ASCII value represented in hexadecimal, and prepends each special character with a percent sign (%).
parameter:
Return value: Returns the URL encoded string.
Example:
// 示例1: $str = "Hello World!"; $encodedStr = rawurlencode($str); echo $encodedStr; // 输出:Hello%20World%21 // 示例2: $str = "hello@php.net"; $encodedStr = rawurlencode($str); echo $encodedStr; // 输出:hello%40php.net // 示例3: $str = "中文"; $encodedStr = rawurlencode($str); echo $encodedStr; // 输出:%E4%B8%AD%E6%96%87
Notes: