関数 html_entity_decode

関数 html_entity_decode は、 HTMLエンティティを対応する文字に変換します。 理解を深めるために例を参照してください。

構文

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

例

タグを含む文字列を変換してみましょう:

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

コード実行結果:

php'<b>text</b>'

例

アンパサンドを含む文字列を変換してみましょう:

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

コード実行結果:

php'test: &'

関連項目