PHP) Example #1 HTML ¿£Æ¼Æ¼ µðÄÚµù |
|
|
 |
10³â Àü |
<?php
$orig = "I'll \"walk\" the <b>dog</b> now";
$a = htmlentities($orig);
$b = html_entity_decode($a);
echo $a; // I'll "walk" the <b>dog</b> now
echo $b; // I'll "walk" the <b>dog</b> now
// PHP 4.3.0 ÀÌÀü »ç¿ëÀÚ´Â ÀÌ·¸°Ô ÇÒ ¼ö ÀÖ½À´Ï´Ù:
function unhtmlentities($string)
{
// ¼ýÀÚ ¿£Æ¼Æ¼ ġȯ
$string = preg_replace('~([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $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; // I'll "walk" the <b>dog</b> now
?>
|
|
̵̧ : 512 |
̵̧
¸ñ·Ï
|
|