mirror of
https://github.com/php/doc-pt_br.git
synced 2026-04-23 16:18:19 +02:00
225 lines
6.8 KiB
XML
225 lines
6.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 45042fef652f1b4e904e809fcbfcf31f6c60670b Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
|
<refentry xml:id="function.html-entity-decode" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>html_entity_decode</refname>
|
|
<refpurpose>Converte entidades HTML aos seus caracteres correspondentes</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>html_entity_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>
|
|
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>html_entity_decode</function> é oposta a
|
|
<function>htmlentities</function> porque converte entidades HTML
|
|
na <parameter>string</parameter> aos seus caracteres correspondentes.
|
|
</para>
|
|
<para>
|
|
Mais precisamente, esta função decodifica todas as entidades (incluindo as
|
|
numéricas): a) que são necessariamente válidas para o tipo de documento escolhido, isto é,
|
|
para XML esta função não decodifica entidades nomeadas que possam ser definidas
|
|
em algum DTD; e b) cujos caracteres estejam no conjunto de caracteres da codificação
|
|
associados com a codificação escolhida e sejam permitidos no tipo de
|
|
documento escolhido. Todas as outras entidades ficarão inalteradas.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A string de entrada.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Uma máscara de bits de uma ou mais das opções a seguir, que especificam como lidar com aspas e
|
|
que tipos de documentos são usados. O padrão é <literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal>.
|
|
<table>
|
|
<title>Constantes disponíveis para <parameter>flags</parameter></title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Nome da Constante</entry>
|
|
<entry>Descrição</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><constant>ENT_COMPAT</constant></entry>
|
|
<entry>Converte aspas duplas e não converte aspas simples.</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_QUOTES</constant></entry>
|
|
<entry>Converte tanto aspas duplas quanto simples.</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_NOQUOTES</constant></entry>
|
|
<entry>Não converte aspas duplas ou simples.</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_SUBSTITUTE</constant></entry>
|
|
<entry>
|
|
Substitui sequências de unidade de código inválidas com um Caractere de Substituição Unicode
|
|
U+FFFD (UTF-8) ou &#xFFFD; ao invés de retornar uma string vazia.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_HTML401</constant></entry>
|
|
<entry>
|
|
Lida com o código como HTML 4.01.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_XML1</constant></entry>
|
|
<entry>
|
|
Lida com o código como XML 1.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_XHTML</constant></entry>
|
|
<entry>
|
|
Lida com o código como XHTML.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_HTML5</constant></entry>
|
|
<entry>
|
|
Lida com o código como HTML 5.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>encoding</parameter></term>
|
|
<listitem>
|
|
&strings.parameter.encoding;
|
|
&reference.strings.charsets;
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna a string decodificada.
|
|
</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>
|
|
O padrão de <parameter>flags</parameter> mudou de <constant>ENT_COMPAT</constant> para <constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant> | <constant>ENT_HTML401</constant>.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>encoding</parameter> agora pode ser nulo.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Decodificando entidades HTML</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$orig = "I'll \"walk\" the <b>dog</b> now";
|
|
|
|
$a = htmlentities($orig);
|
|
|
|
$b = html_entity_decode($a);
|
|
|
|
echo $a, PHP_EOL; // I'll "walk" the <b>dog</b> now
|
|
|
|
echo $b, PHP_EOL; // I'll "walk" the <b>dog</b> now
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Pode-se perguntar por que trim(html_entity_decode('&nbsp;')); não
|
|
reduz a string a uma string vazia, e isso acontece porque a entidades
|
|
'&nbsp;' não tem código ASCII 32 (que é o código removido por
|
|
<function>trim</function>) mas sim 160 (0xa0) na codificação padrão
|
|
ISO 8859-1.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>htmlentities</function></member>
|
|
<member><function>htmlspecialchars</function></member>
|
|
<member><function>get_html_translation_table</function></member>
|
|
<member><function>urldecode</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
|
|
-->
|