mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-27 10:22:07 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@228249 c90b9560-bf6c-de11-be94-00142212c4b1
151 lines
4.7 KiB
XML
151 lines
4.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.14 $ -->
|
|
<!-- EN-Revision: 1.12 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
|
|
<refentry id="function.html-entity-decode">
|
|
<refnamediv>
|
|
<refname>html_entity_decode</refname>
|
|
<refpurpose>
|
|
Convertit toutes les entités HTML en caractères normaux
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&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>quote_style</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>charset</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>html_entity_decode</function> est la fonction contraire de
|
|
<function>htmlentities</function> : elle convertit les entités HTML de
|
|
la chaîne <parameter>string</parameter> en caractères normaux.
|
|
</para>
|
|
<para>
|
|
Le paramètre optionnel <parameter>quote_style</parameter> vous permet de
|
|
définir ce qu'il adviendra des guillemets simples et doubles. Ce
|
|
paramètre prend l'une des valeurs suivantes (et la valeur par défaut
|
|
est <constant>ENT_COMPAT</constant>) :
|
|
<table>
|
|
<title>
|
|
Constantes disponibles pour <parameter>quote_style</parameter>
|
|
</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Constante</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><constant>ENT_COMPAT</constant></entry>
|
|
<entry>
|
|
Convertit les guillemets doubles et
|
|
ignore les guillemets simples.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_QUOTES</constant></entry>
|
|
<entry>
|
|
Convertit les guillemets doubles et les guillemets simples.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><constant>ENT_NOQUOTES</constant></entry>
|
|
<entry>Ne convertit aucun guillemet.</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
<para>
|
|
Le jeu de caractères ISO-8859-1 est utilisé par défaut,
|
|
comme paramètre <parameter>charset</parameter>. Ce paramètre
|
|
permet de choisir le jeu de caractères utilisé dans la conversion.
|
|
</para>
|
|
&reference.strings.charsets;
|
|
<para>
|
|
<note>
|
|
<para>
|
|
Cette fonction ne supporte pas les jeux de caractères multi-octets dans
|
|
&php; < 5.
|
|
</para>
|
|
</note>
|
|
<example>
|
|
<title>Décoder des entités HTML</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$orig = 'J\'ai "sorti" le <strong>chien</strong> tout à l\'heure';
|
|
$a = htmlentities($orig);
|
|
$b = html_entity_decode($a);
|
|
|
|
echo $a; // J'ai "sorti" le <strong>chien</strong> tout &agrave; l'heure
|
|
echo $b; // J'ai "sorti" le <strong>chien</strong> tout à l'heure
|
|
|
|
// Pour les utilisateurs ayant des versions antérieures à PHP 4.3.0 :
|
|
function unhtmlentities ($string)
|
|
{
|
|
// Remplace les entités numériques
|
|
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
|
|
$string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string);
|
|
// Remplace les entités litérales
|
|
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
|
|
$trans_tbl = array_flip ($trans_tbl);
|
|
return strtr ($string, $trans_tbl);
|
|
}
|
|
|
|
$c = unhtmlentities($a);
|
|
echo $c; // J'ai "sorti" le <strong>chien</strong> tout à l'heure
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<note>
|
|
<para>
|
|
Vous pourriez vous demander pourquoi
|
|
<literal>trim(html_entity_decode('&nbsp;'));</literal>
|
|
ne réduit pas la chaîne à la chaîne vide. C'est parce
|
|
que l'entité <literal>&nbsp;</literal>
|
|
n'est pas un code ASCII 32 (qui serait supprimé par
|
|
<function>trim</function>) mais un code ASCII 160 (0xa0)
|
|
dans le jeu de caractères par défaut <literal>ISO 8859-1</literal>.
|
|
</para>
|
|
</note>
|
|
</para>
|
|
<para>
|
|
Voir aussi
|
|
<function>htmlentities</function>,
|
|
<function>get_html_translation_table</function>,
|
|
<function>htmlspecialchars</function> et
|
|
<function>urldecode</function>.
|
|
</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:"../../../../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
|
|
-->
|