1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-24 15:12:22 +01:00
Files
archived-doc-ja/reference/strings/functions/htmlspecialchars-decode.xml
2021-12-31 09:27:16 +09:00

205 lines
6.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: eabde0419cf90f596f60db00e31fcb6ebe41ac55 Maintainer: takagi Status: ready -->
<!-- Credits: mumumu -->
<refentry xml:id="function.htmlspecialchars-decode" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>htmlspecialchars_decode</refname>
<refpurpose>
特殊な HTML エンティティを文字に戻す
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>htmlspecialchars_decode</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</initializer></methodparam>
</methodsynopsis>
<para>
この関数は <function>htmlspecialchars</function> の反対です。
特殊な HTML エンティティを文字に戻します。
</para>
<para>
変換されるエンティティは次のものです。<literal>&amp;amp;</literal>
<literal>&amp;quot;</literal> (<constant>ENT_NOQUOTES</constant> が設定されていない場合)、
<literal>&amp;#039;</literal> (<constant>ENT_QUOTES</constant> が設定されている場合)、
<literal>&amp;lt;</literal> および <literal>&amp;gt;</literal>
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
デコードする文字列。
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
以下のフラグのビットマスクによる組み合わせで、クォートの扱いやドキュメントの形式を指定します。
デフォルトは <literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal> です。
<table>
<title>使用可能な <parameter>flags</parameter> 定数</title>
<tgroup cols="2">
<thead>
<row>
<entry>定数名</entry>
<entry>説明</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>ENT_COMPAT</constant></entry>
<entry>ダブルクォートを変換し、シングルクォートはそのままにします。</entry>
</row>
<row>
<entry><constant>ENT_QUOTES</constant></entry>
<entry>ダブルクォート、シングルクォートの両方を変換します。</entry>
</row>
<row>
<entry><constant>ENT_NOQUOTES</constant></entry>
<entry>ダブルクォート、シングルクォートの両方をそのままにします。</entry>
</row>
<row>
<entry><constant>ENT_SUBSTITUTE</constant></entry>
<entry>
無効な符号単位シーケンスを含む文字列を渡したときに、
空の文字列を返すのではなく Unicode の置換文字に置き換えます。
UTF-8 の場合は U+FFFD、それ以外の場合は &amp;#FFFD; となります。
</entry>
</row>
<row>
<entry><constant>ENT_HTML401</constant></entry>
<entry>
コードを HTML 4.01 として処理します。
</entry>
</row>
<row>
<entry><constant>ENT_XML1</constant></entry>
<entry>
コードを XML 1 として処理します。
</entry>
</row>
<row>
<entry><constant>ENT_XHTML</constant></entry>
<entry>
コードを XHTML として処理します。
</entry>
</row>
<row>
<entry><constant>ENT_HTML5</constant></entry>
<entry>
コードを HTML 5 として処理します。
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
デコードされた文字列を返します。
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.1.0</entry>
<entry>
<parameter>flags</parameter> のデフォルト値が
<constant>ENT_COMPAT</constant> から
<constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant> | <constant>ENT_HTML401</constant>
に変更されました。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>htmlspecialchars_decode</function> の例</title>
<programlisting role="php">
<![CDATA[
<?php
$str = "<p>this -&gt; &quot;</p>\n";
echo htmlspecialchars_decode($str);
// クォートが変換されないことに注意しましょう
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
<p>this -> "</p>
<p>this -> &quot;</p>
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>htmlspecialchars</function></member>
<member><function>html_entity_decode</function></member>
<member><function>get_html_translation_table</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->