urlencode rawurlencode htmlspecialchars htmlentities

來源:互聯網
上載者:User

標籤:get   格式   eric   nal   string   情況   orm   desc   二進位   

w

 

 

string urlencode ( string $str )

返回字串,此字串中除了 -_. 之外的所有非字母數字字元都將被替換成百分比符號(%)後跟兩位十六進位數,空格則編碼為加號(+)。此編碼與 WWW 表單 POST 資料的編碼方式是一樣的,同時與 application/x-www-form-urlencoded 的媒體類型編碼方式一樣。由於曆史原因,此編碼在將空格編碼為加號(+)方面與 ? RFC3896 編碼(參見 rawurlencode())不同。   

 

 

string rawurlencode ( string $str )

返回字串,此字串中除了 -_. 之外的所有非字母數字字元都將被替換成百分比符號(%)後跟兩位十六進位數。這是在 ? RFC 3986 中描述的編碼,是為了保護原義字元以免其被解釋為特殊的 URL 定界符,同時保護 URL 格式以免其被傳輸媒體(像一些郵件系統)使用字元轉換時弄亂。    

 

string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = true ]]] )

    某類字元在 HTML 中有特殊用處,如需保持原意,需要用 HTML 實體來表達。 本函數會返回字元轉義後的表達。 如需轉換子字串中所有關聯的名稱實體,使用 htmlentities() 代替本函數。

如果傳入字元的字元編碼和最終的文檔是一致的,則用函數處理的輸入適合絕大多數 HTML 文檔環境。 然而,如果輸入的字元編碼和最終包含字元的文檔是不一樣的, 想要保留字元(以數字或名稱實體的形式),本函數以及 htmlentities() (僅編碼名稱實體對應的子字串)可能不夠用。 這種情況可以使用 mb_encode_numericentity() 代替。   

 

string htmlentities ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = true ]]] )

本函數各方面都和 htmlspecialchars() 一樣, 除了 htmlentities() 會轉換所有具有 HTML 實體的字元。

如果要解碼(反向操作),可以使用 html_entity_decode()。   

 

 

string base64_encode ( string $data )

使用 base64 對 data 進行編碼。

設計此種編碼是為了使位元據可以通過非純 8-bit 的傳輸層傳輸,例如電子郵件的主體。

Base64-encoded 資料要比未經處理資料多佔用 33% 左右的空間。   

 

urlencode rawurlencode htmlspecialchars htmlentities

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.