PHP方法)_entity_decode()


PHP公式サイトの紹介はより詳細です。
http://www.php.net/manual/en/function.html-entity-decode.php
 
Theentity_decode()function converts HTML entities to characters.htmlentity_decode()関数の役割は、HTML文字を文字に変換することです。
Theentity_decode()function is the opposite of httmlentities(.)htmlentity_decode()関数の役割は和です。 httmlentitiesは逆です。
Syntax文法
html_entity_decode(string,quotestyle,character-set)
 
パラメータ
Descriptionの説明
ストリングス
Required.Specifies the string to decode必要パラメータです。復号する文字列オブジェクトを指定します。
quot testyle.
Optional.Specifies how to decode single and double quot.オプションパラメータ。シングルクォーテーションマークとダブルクォーテーションマークをエンコードする方法を指定します。デフォルトはENT_ですCOMPATThe available quot te style are:可能な値:
  • ENT_COMPAT-Default.Decodes only double quot tes ENT_COMPAT–二重引用符を符号化し、単引用符を符号化しない
  • ENT_QUOTES-Decodes double and single quot tes ENT_QUOTES–単引用符と二重引用符を符号化
  • ENT_NOQUOTES-Does not decode any quot tes ENT_NOQUOTES–シングル引用符またはダブルクォーテーションマークを符号化しない
  • character-set
    Optional.A string that specifies which character-set to use.オプションパラメータ。どのような文字列でAllowed values areを設定するかを指定します。利用可能な値は以下の通りです。
  • ISO-859-1-Default.Wester n European ISO-859-1–標準値。西欧語
  • ISO-859-15-Wester n European(adds the Euro sign+Freench and Finnish letters missing in ISO-859-15–西欧文(ISO-859-1にない記号+フランス語とフィンランド文字を入れました)
  • UTF-8-ASCII comptible multie-byte 8-bit Uniode UTF-8–ASCII対応の多バイト8ビットに統一された文字コード標準
  • cp 866-DOS-specific Cyrillic charset cp 866–DOS–詳細な西爾里[Cyrillic]文字設定
  • cp 1251-Windows-specific Cyrillic charset cp 1251–Windows-詳細な西爾里[Cyrillic]文字設定
  • cp 1252-Windows specific charset for Wester n European cp 1252–Windws–詳細な西欧フォントのフォント属性
  • KOI 8-R-Russian KOI 8-R–ロシア文
  • BIG 5-Traditional Chinese、manly used in Taiwan BIG 5–繁体字中国語は主に台湾で使う
  • GB 2312-Simplified Chinese、national standard character set GB 2312–簡体字中国語は、主に中国大陸で使われる
  • BIG 5-HKSCS-Big 5 with Hong Kons BIG 5-HKSCS–香港で使うBig 5拡張
  • Shift_JIS-Japanese Shift_JIS–日本語
  • EUC-JP-Japanese EUC-JP–日本語
  •  
    Tips and Notes注意点
    Note:Urecognized character-sets will be ignored and replacced by ISO-859-1.識別できないフォント設定が無視され、ISO-859-1を使用します。
    Example 1ケース1
    <?php

    $str = "Jane &amp; &#039;Tarzan&#039;";

    echo html_entity_decode($str);

    echo "<br />";

    echo html_entity_decode($str, ENT_QUOTES);

    echo "<br />";

    echo html_entity_decode($str, ENT_NOQUOTES);

    ?>
    The browser output of the code aboff will be:上記のコードは以下の結果を出力します。
    Jane & 'Tarzan'

    Jane & 'Tarzan'

    Jane & 'Tarzan'
    If you select「View source」in the browser window,you will see the following HTML:ブラウザで「ソースファイルを確認する」を選択すると、以下のHTMLデータの流れが見えます。
    <html>

    <body>

    Jane & &#039;Tarzan&#039;<br />

    Jane & 'Tarzan'<br />

    Jane & &#039;Tarzan&#039;

    </body>

    </html>
     
    Example 2ケース2
    <html>

    <body>

    <?php

    $str = "My name is &Oslash;yvind &Aring;sane. I&#039;m Norwegian";

    echo html_entity_decode($str, ENT_QUOTES, "ISO-8859-1");

    ?>

    </body>

    </html>
    The browser output of the code aboff will be:上記のコードは以下の結果を出力します。
    My name is Øyvind Åsane. I'm Norwegian
    If you select「View source」in the browser window,you will see the following HTML:ブラウザで「ソースファイルを確認する」を選択すると、以下のHTMLデータの流れが見えます。
    <html>

    <body>

    My name is Øyvind Åsane. I'm Norwegian

    </body>

    </html>