相關的函式:
htmlspecialchars - 轉換HTML的特別字元
'&' (ampersand) becomes '&'
'"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
''' (single quote) becomes ''' only when ENT_QUOTES is set.
'<' (less than) becomes '<' '>' (greater than) becomes '>'
htmlentities - 全部字元都轉換
差別:
$str = "test>ä";
echo $str; //test>ä
echo htmlentities($str); //test>ä
echo htmlspecialchars($str); //test>ä
沒有留言:
張貼留言