วันอาทิตย์ที่ 11 พฤษภาคม พ.ศ. 2557

20:02
ฟังก์ชัน htmlentities()
เปลี่ยนตัวอักษรให้เป็น HTML entities ด้วยฟังก์ชัน htmlentities()

 

รูปแบบ
htmlentities(string , quotestyle , character-set )

string
 คือ สตริงที่ต้องการ

quotestyle คือ 
ENT_COMPAT - Encodes เฉพาะ double quotes (Default)
ENT_QUOTES - Encodes double และ single quotes
ENT_NOQUOTES - ไม่ encode any quotes 

character-set
 คือ สตริงที่ต้องการ 
ISO-8859-1 - Default. Western European
ISO-8859-15 - Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1)
UTF-8 - ASCII compatible multi-byte 8-bit Unicode
cp866 - DOS-specific Cyrillic charset
cp1251 - Windows-specific Cyrillic charset
cp1252 - Windows specific charset for Western European
KOI8-R - Russian
BIG5 - Traditional Chinese, mainly used in Taiwan
GB2312 - Simplified Chinese, national standard character set
BIG5-HKSCS - Big5 with Hong Kong extensions
Shift_JIS - Japanese
EUC-JP - Japanese 

ตัวอย่าง
<?php

$str = "R & B song";
$str2 = htmlentities($str, ENT_QUOTES);

?>

จากตัวอย่าง $str2 จะมีค่าเป็น R &amp; B song

0 ความคิดเห็น:

แสดงความคิดเห็น