鏈接:https://blog.csdn.net/tashanhongye/article/details/49668835
urlencode()函數原理就是首先把中文字符轉換為十六進制,然后在每個字符前面加一個標識符%,對字符串中除了 -_. 之外的所有非字母數字字符都將被替換成百分號(%)后跟兩位十六進制數,空格則編碼為加號(+)。
urldecode()函數與urlencode()函數原理相反,用於解碼已編碼的 URL 字符串,其原理就是把十六進制字符串轉換為中文字符。
urlencode()函數原理就是首先把中文字符轉換為十六進制,然后在每個字符前面加一個標識符%,對字符串中除了 -_. 之外的所有非字母數字字符都將被替換成百分號(%)后跟兩位十六進制數,空格則編碼為加號(+)。 urldecode()函數與urlencode()函數原理相反,用於解碼已編碼的 URL 字符串,其原理就是把十六進制字符串轉換為中文字符。 For Example: index.html <?php header("Content-Type:text/html;charset=utf-8"); $parm=urlencode("演示PHP-MYSQL"); $url="index.php?par=".$parm; ?> <!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Strict//EN' 'http://www.w3.org/TR/html4/strict.dtd'> <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> <title>insert into title</title> </head> <body> <a href="<?php echo $url;?>">urlencode演示</a> </body> </html> url輸出結果:http://localhost/namespace2/space2/index3.php?par=%E6%BC%94%E7%A4%BAPHP-MYSQL index.php $parValue=$_GET['par']; echo urldecode($parValue); OutPut: 演示PHP-MYSQL
