ฟังก์ชัน htmlspecialchars_decode

ฟังก์ชัน htmlspecialchars_decode ดำเนินการ ตรงข้ามกับฟังก์ชัน htmlspecialchars

ไวยากรณ์

phphtmlspecialchars_decode(string $string, int $flags = ENT_COMPAT): string

ตัวอย่าง

มาแปลงสตริงที่มีแท็กกัน:

php<?php
  $str = '<b>text</b>';
  $res = htmlspecialchars_decode($str);
  
  echo $res;
?>

ผลลัพธ์ของการรันโค้ด:

php'<b>text</b>'

ดูเพิ่มเติม

  • ฟังก์ชัน html_entity_decode,
    ซึ่งดำเนินการคล้ายกัน
  • ฟังก์ชัน htmlspecialchars,
    ซึ่งดำเนินการตรงกันข้าม