[b]htmlspecialchars[/b]
(PHP 3, PHP 4 )
把html语言的特殊标记变成转义的符号
htmlspecialchars -- Convert special characters to HTML entities
Description
string htmlspecialchars ( string string [, int quote_style [, string charset]])
'&' (ampersand) becomes '&'
'"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
''' (single quote) becomes ''' only when ENT_QUOTES is set.
'<' (less than) becomes '<'
'>' (greater than) becomes '>'
例子 1. htmlspecialchars() example
[code]
$new = htmlspecialchars("
Test", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?>
[b]htmlentities[/b]
(PHP 3, PHP 4 )
htmlentities -- Convert all applicable characters to HTML entities
与前一个函数相同,但是他是把所有的字符转换了
[b]nl2br[/b]
(PHP 3, PHP 4 )
nl2br -- Inserts HTML line breaks before all newlines in a string
字符串中有换行标记的转换成html 的
[/code]