Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3387

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Convert special HTML entities back to characters</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.htmlentities.html">htmlentities</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.htmlspecialchars.html">htmlspecialchars</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.htmlspecialchars-decode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">htmlspecialchars_decode</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">htmlspecialchars_decode</span> &mdash; <span class="dc-title">
   Convert special HTML entities back to characters
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.htmlspecialchars-decode-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>htmlspecialchars_decode</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = ENT_COMPAT | ENT_HTML401</span></span>
  ] )</div>


  <p class="para rdfs-comment">
   This function is the opposite of  <span class="function"><a href="function.htmlspecialchars.html" class="function">htmlspecialchars()</a></span>. It
   converts special HTML entities back to characters.
  </p>
  <p class="para">
   The converted entities are: <em>&amp;amp;</em>,
   <em>&amp;quot;</em> (when <strong><code>ENT_NOQUOTES</code></strong> is not set),
   <em>&amp;#039;</em> (when <strong><code>ENT_QUOTES</code></strong> is set),
   <em>&amp;lt;</em> and <em>&amp;gt;</em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.htmlspecialchars-decode-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">string</code></em></span>
     <dd>

      <p class="para">
       The string to decode.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">flags</code></em></span>
     <dd>

      <p class="para">
       A bitmask of one or more of the following flags, which specify how to handle quotes and
       which document type to use. The default is <em>ENT_COMPAT | ENT_HTML401</em>.
       <table class="doctable table">
        <caption><strong>Available <em><code class="parameter">flags</code></em> constants</strong></caption>
        
         <thead>
          <tr>
           <th>Constant Name</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><strong><code>ENT_COMPAT</code></strong></td>
           <td>Will convert double-quotes and leave single-quotes alone.</td>
          </tr>

          <tr>
           <td><strong><code>ENT_QUOTES</code></strong></td>
           <td>Will convert both double and single quotes.</td>
          </tr>

          <tr>
           <td><strong><code>ENT_NOQUOTES</code></strong></td>
           <td>Will leave both double and single quotes unconverted.</td>
          </tr>

          <tr>
           <td><strong><code>ENT_HTML401</code></strong></td>
           <td>
            Handle code as HTML 4.01.
           </td>
          </tr>

          <tr>
           <td><strong><code>ENT_XML1</code></strong></td>
           <td>
            Handle code as XML 1.
           </td>
          </tr>

          <tr>
           <td><strong><code>ENT_XHTML</code></strong></td>
           <td>
            Handle code as XHTML.
           </td>
          </tr>

          <tr>
           <td><strong><code>ENT_HTML5</code></strong></td>
           <td>
            Handle code as HTML 5.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.htmlspecialchars-decode-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the decoded string.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.htmlspecialchars-decode-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.4.0</td>
       <td>
        The constants <strong><code>ENT_HTML401</code></strong>, <strong><code>ENT_XML1</code></strong>,
        <strong><code>ENT_XHTML</code></strong> and <strong><code>ENT_HTML5</code></strong> were added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.htmlspecialchars-decode-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4838">
    <p><strong>Example #1 A  <span class="function"><strong>htmlspecialchars_decode()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"&lt;p&gt;this&nbsp;-&amp;gt;&nbsp;&amp;quot;&lt;/p&gt;\n"</span><span style="color: #007700">;<br /><br />echo&nbsp;</span><span style="color: #0000BB">htmlspecialchars_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;note&nbsp;that&nbsp;here&nbsp;the&nbsp;quotes&nbsp;aren't&nbsp;converted<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">htmlspecialchars_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">ENT_NOQUOTES</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
&lt;p&gt;this -&gt; &quot;&lt;/p&gt;
&lt;p&gt;this -&gt; &amp;quot;&lt;/p&gt;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.htmlspecialchars-decode-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.htmlspecialchars.html" class="function" rel="rdfs-seeAlso">htmlspecialchars()</a> - Convert special characters to HTML entities</span></li>
    <li class="member"> <span class="function"><a href="function.html-entity-decode.html" class="function" rel="rdfs-seeAlso">html_entity_decode()</a> - Convert all HTML entities to their applicable characters</span></li>
    <li class="member"> <span class="function"><a href="function.get-html-translation-table.html" class="function" rel="rdfs-seeAlso">get_html_translation_table()</a> - Returns the translation table used by htmlspecialchars and htmlentities</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.htmlentities.html">htmlentities</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.htmlspecialchars.html">htmlspecialchars</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>