นาย ณัฐพล กรงเงิน รหัสนีกศึกษา 544244062
วิชา COMP353 การพัฒนาโปรแกรมประยุกต์บนเว็บ
สาขาวิชา วิทยาการคอมพิวเตอร์ กลุ่ม 2
ชื่องาน (PHP function.3.16) get_html_translation_table
ชื่อฟังก์ชัน : get_html_translation_table ( table , style )
คำอธิบาย : ใช้คืนค่าเครื่องหมายพิเศษของภาษา html ทั้งหมด
ถ้า table = HTML_SPECIALCHARS จะแสดงเครื่องหมายพิเศษที่ใช้กับ htmlspecialchars() ( default )
ถ้า table = HTML_ENTITIES จะแสดงเรื่องหมายพิเศษที่ใช้กับ htmlentities()
style คือรูปแบบการเปลี่ยนเครื่องหมายคำพูด
ถ้า style = ENT_COMPAT คือกำหนดให้แปลงเครื่องหมาย double quote แค่คง single quote ไว้
ถ้า style = ENT_QUOTES คือกำหนดให้แปลงทั้งเครื่องหมาย double quote และ single quote
ถ้า style = ENT_NOQUOTES คือกำหนดไม่ให้แปลงทั้งเครื่องหมาย double quote และ single quote
ส่วนที่ 2
ตัวอย่างที่ 1
$trans = get_html_translation_table(HTML_ENTITIES);
$str = "Hallo & <Frau> & Krämer";
$encoded = strtr($str, $trans);
echo $encoded;
ผลที่ได้
Hallo & <Frau> & Krämer
ส่วนที่ 3
ตัวอย่างที่ 2
$table = HTML_SPECIALCHARS;
$quote_style = ENT_QUOTES;
$result = get_html_translation_table ($table, $quote_style);
ผลที่ได้
array (
'&' => '&',
'"' => '"',
''' => ''',
'<' => '<',
'>' => '>',
);