PHP - htmlentities 函式



語法

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

定義和用法

它用於將所有適用的字元轉換為 HTML 實體。

返回值

它返回編碼後的字串。

引數

序號 引數和描述
1

string

包含輸入字串的資訊

2

flags

包含標誌的資訊

3

encoding

這是一個可選引數,定義轉換字元時使用的編碼。

示例

嘗試以下示例

<?php
   $str = "PHP Function htmlentities";
   
   echo htmlentities($str);
   echo htmlentities($str, ENT_QUOTES);
?>

這將產生以下結果 - -

PHP Function htmlentitiesPHP Function htmlentities
php_function_reference.htm
廣告