FREEBOX IV

かりっちのブログ 《 超個人的メモブログ 》

【PHP】HTMLエンティティ変換(逆変換)

2006年09月16日 | Tips

■特殊文字 -> HTMLエンティティ ( '&'  -> '&' )

string htmlspecialchars ( string string, int <VAR class=replaceable>[quote_style]</VAR> [, string charset] )
string htmlentities ( string string, int <VAR class=replaceable>[quote_style]</VAR>, string <VAR class=replaceable>[charset]</VAR> )

■HTMLエンティティ ->特殊文字  ( '&amp;'  -> '&' )

<?php
function unhtmlentities ($string
)
{
    
$trans_tbl = get_html_translation_table (HTML_ENTITIES
);
    
$trans_tbl = array_flip ($trans_tbl
);
    return
strtr ($string, $trans_tbl
);
}
?>


最新の画像もっと見る