ฟังก์ชัน html_entity_decode
html_entity_decode แปลง
เอนทิตี HTML เป็นอักขระที่ตรงกัน
ดูตัวอย่างเพื่อความเข้าใจที่ดีขึ้น
ไวยากรณ์
html_entity_decode(string $string, int $flags = ENT_COMPAT, ?string $encoding = null): string
ตัวอย่าง
ลองแปลงสตริงที่มีแท็ก:
<?php
$str = '<b>text</b>';
$res = html_entity_decode($str);
echo $res;
?>
ผลลัพธ์จากการรันโค้ด:
'<b>text</b>'
ตัวอย่าง
ลองแปลงสตริงที่มี เครื่องหมายแอมเพอร์แซนด์:
<?php
$str = 'test: &';
$res = html_entity_decode($str);
echo $res;
?>
ผลลัพธ์จากการรันโค้ด:
'test: &'
ดูเพิ่มเติม
-
htmlentities,
ซึ่งทำงานตรงกันข้าม -
htmlspecialchars,
ซึ่งทำงานที่คล้ายกันในทางตรงกันข้าม