php urlencode 與 rawurlencode 教程rawurlencode
( PHP 4中, PHP 5中)
rawurlencode -網址編碼根據的RFC 1738
描述
字串rawurlencode (字串$str)
編碼特定字串根據»的RFC 1738 。
參數
str
將URL進行編碼。
傳回值
返回一個字串中的所有非字母數字字元除了- _ 。被替換成一個百分比符號( % )符號後面跟兩個十六進位數字。這是編碼描述»的RFC 1738年為保護字面字元被解釋為特殊的URL分隔和保護的URL被毀損的傳輸媒體轉換與性質(如一些電子郵件系統) 。
執行個體
例如# 1包括一個密碼的FTP網址
$a = explode('&', $QUERY_STRING);
$i = 0;
while ($i < count($a)) {
$b = split('=', $a[$i]);
echo 'Value for parameter ', htmlspecialchars(urldecode($b[0])),
' is ', htmlspecialchars(urldecode($b[1])), "
n";
$i++;
}
?>
進行urlencode
( PHP 4中, PHP 5中)
進行urlencode -網址編碼字串
描述
字串進行urlencode (字串$str)
此功能方便的編碼字串被用於查詢的網址的一部分,作為一種便捷的方式傳遞變數的下一頁。
參數
str
字串編碼。
傳回值
返回一個字串中的所有非字母數字字元除了- _ 。被替換成一個百分比符號( % )符號後面跟兩個十六進位數字和空格編碼為加號( + )的跡象。這是相同的編碼方式,從公布的資料編碼的WWW形式,這是同樣的方式在應用/的X WWW的形式了urlencoded的媒體類型。這不同於參考» RFC 1738編碼(見rawurlencode ( ) )中,對曆史的原因,空格編碼為加號( + )的跡象。
執行個體
例如# 1進行urlencode ( )的例子
echo '';
?>
Example #2 urlencode() and htmlentities() example
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '';
?>
http://www.bkjia.com/PHPjc/630888.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630888.htmlTechArticlephp urlencode 與 rawurlencode 教程rawurlencode ( PHP 4中, PHP 5中) rawurlencode -網址編碼根據的RFC 1738 描述 字串rawurlencode (字串$str) 編碼特定...