php urlencode 與 rawurlencode 教程_PHP教程

來源:互聯網
上載者:User
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) 編碼特定...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.