|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
htmlspecialchars_decode (PHP 5) htmlspecialchars_decode --
Convert special HTML entities back to characters
Opisstring htmlspecialchars_decode ( string string [, int quote_style] )
This function is the opposite of htmlspecialchars(). It
converts special HTML entities back to characters.
The converted entities are: &,
" (when ENT_NOQUOTES is not set),
' (when ENT_QUOTES is set),
< and >.
Parametry
- string
The string to decode
- quote_style
The quote style. One of the following constants:
Tabela 1. quote_style constants | Constant Name | Description |
|---|
| ENT_COMPAT | Will convert double-quotes and leave single-quotes alone
(default) | | ENT_QUOTES | Will convert both double and single quotes | | ENT_NOQUOTES | Will leave both double and single quotes unconverted |
Zwracane wartości
Returns the decoded string.
Przykłady
Przykład 1. A htmlspecialchars_decode() example |
<?php
$str = '<p>this -> "</p>';
echo htmlspecialchars_decode($str);
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>
|
Powyższy przykład wyświetli: <p>this -> "</p>
<p>this -> "</p> |
|
User Contributed Notesse at designlinks dot net
14-Dec-2005 05:43
The code supplied by or-k at or-k dot com (14-Sep-2005 09:15) is better served using html_entity_decode() for PHP>=4.3.0.
geoffers@gmail (14-Jul-2005 01:38) offers the best htmlspecialchars_decode() for php4 users.
or-k at or-k dot com
14-Sep-2005 11:15
that works also with ä and " and so on.
get_html_translation_table(HTML_ENTITIES) => offers more characters than HTML_SPECIALCHARS
function htmlspecialchars_decode_PHP4($uSTR)
{
return strtr($uSTR, array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES)));
}
geoffers@gmail
14-Jul-2005 03:38
[Update of previous note, having noticed I forgot to put in quote style]
PHP4 Compatible function:
<?php
function htmlspecialchars_decode_php4 ($str, $quote_style = ENT_COMPAT) {
return strtr($str, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
}
?>
geoffers at gmail dot com
14-Jul-2005 03:30
For PHP4 Compatibility:
<?php
function htmlspecialchars_decode_php4 ($str) {
return strtr($str, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
}
?>
|