' & #39; htmlspecialchars_decode 변환
로빈아빠
본문
$str="' 최고얼짱은 한국인! '";
$str=htmlspecialchars_decode($str, ENT_QUOTES);
echo "<XMP>$str\n";
echo "<XMP>",htmlspecialchars_decode($str);
exit;
var_dump(get_html_translation_table(HTML_SPECIALCHARS,ENT_QUOTES));
var_dump(htmlspecialchars('\'',ENT_QUOTES));
?>
--------------------
Output:
--------------------
array
'"' => '"'
''' => '''
'<' => '<'
'>' => '>'
'&' => '&'
'''
--------------------
This comment now is not to report this bug again (though I really believe it is one), but to complete the example and warn people of this pitfall.
To make sure your htmlspecialchars_decode fake for PHP4 works, you should do something like this:
<?php
function htmlspecialchars_decode($string,$style=ENT_COMPAT)
{
$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS,$style));
if($style === ENT_QUOTES){ $translation['''] = '\''; }
return strtr($string,$translation);
}
?>
댓글목록
등록된 댓글이 없습니다.