cvs: phpdoc-da /reference/strings/functions html-entity-decode.xml
[email protected] ("Jonathan Holst") Thu, 14 Oct 2004 20:13:25 -0000
| Newsgroups | php.doc.da |
|---|---|
| Message-ID | <cvsholst1097784804@cvsserver> |
holst Thu Oct 14 16:13:25 2004 EDT
Added files:
/phpdoc-da/reference/strings/functions html-entity-decode.xml
Log:
Initial translation
http://cvs.php.net/co.php/phpdoc-da/reference/strings/functions/html-entity-decode.xml?r=1.1&p=1
Index: phpdoc-da/reference/strings/functions/html-entity-decode.xml
+++ phpdoc-da/reference/strings/functions/html-entity-decode.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- EN-Revision: 1.9 Maintainer: holst Status: ready -->
<refentry id="function.html-entity-decode">
<refnamediv>
<refname>html_entity_decode</refname>
<refpurpose>
Koverter alle HTML-entiteter til deres anvendelige tegn
</refpurpose>
</refnamediv>
<refsect1>
<title>Beskrivelse</title>
<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> er det modsatte af
<function>htmlentities</function>, da den konverterer alle HTML-entiteter
til deres anvendelige tegn fra <parameter>string</parameter>.
</para>
<para>
Den valgfrie anden <parameter>quote_style</parameter>-parameter lader dig
definere hvad der skal gøres med 'enkelte' og "dobbelte" citationstegn.
Den tager en af tre konstanter med <constant>ENT_COMPAT</constant> som
standard:
<table>
<title>Tilgængelige <parameter>quote_style</parameter> konstanter</title>
<tgroup cols="2">
<thead>
<row>
<entry>Konstant Navn</entry>
<entry>Beskrivelse</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>ENT_COMPAT</constant></entry>
<entry>Vil konvertere dobbelte citationstegn og lade enkelte
være.</entry>
</row>
<row>
<entry><constant>ENT_QUOTES</constant></entry>
<entry>Vil konvertere både dobbelte og enkelte citationstegn.</entry>
</row>
<row>
<entry><constant>ENT_NOQUOTES</constant></entry>
<entry>Vil lade både dobbelte og enkelte citationstegn være.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
ISO-8859-1 tegnsættet er standardværdi for den valgfrie tredje
<parameter>charset</parameter>. Denne definerer tegnsættet brugt i
konverteringen.
</para>
&reference.strings.charsets;
<para>
<example>
<title>Dekode HTML-entiteter</title>
<programlisting role="php">
<![CDATA[
<?php
$orig = "Du sku' \"gå\" tur med <b>hunden</b> nu";
$a = htmlentities($orig);
$b = html_entity_decode($a);
echo $a; // Du sku' "gå" tur med <b>hunden</b> nu
echo $b; // Du sku' "gå" tur med <b>hunden</b> nu
// For versioner tidligere end PHP 4.3.0 kan du gøre dette:
function unhtmlentities($string)
{
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
$c = unhtmlentities($a);
echo $c; // Du sku' "gå" tur med <b>hunden</b> nu
?>
]]>
</programlisting>
</example>
</para>
<para>
<note>
<para>
You might wonder why trim(html_entity_decode('&nbsp;')); doesn't
reduce the string to an empty string, that's because the '&nbsp;'
entity is not ASCII code 32 (which is stripped by
<function>trim</function>) but ASCII code 160 (0xa0) in the default ISO
8859-1 characterset.
</para>
</note>
</para>
<para>
See also <function>htmlentities</function>,
<function>htmlspecialchars</function>,
<function>get_html_translation_table</function>,
and <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
-->