Funkcija html_entity_decode

Funkcija html_entity_decode pārvērš HTML entītijas atbilstošos simbolos. Skatiet piemērus labākai izpratnei.

Sintakse

phphtml_entity_decode(string $string, int $flags = ENT_COMPAT, ?string $encoding = null): string

Piemērs

Pārveidosim virkni ar tagiem:

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

Koda izpildes rezultāts:

php'<b>text</b>'

Piemērs

Pārveidosim virkni ar ampersandu:

php<?php
  $str = 'test: &';
  $res = html_entity_decode($str);
  
  echo $res;
?>

Koda izpildes rezultāts:

php'test: &'

Skatiet arī