1,stripslashes addslashes
字符串的转义操作vs取消转义
form表里面提交的字符串将一些字符,比如’,”,\等自动添加\转义成为\’,\”,\\,可以使用函数
string stripslashes ( string str )
与此相反,添加转义\字符,可以使用string addslashes ( string str )
2,htmlentities htmlspecialchars html_entity_decode htmlspecialchars_decode()
显示html和js代码vs执行代码
有些用户添加一些js代码,然而我们不希望他们执行,仅仅让他们显示,可以使用函数
string htmlentities ( string string [, int quote_style [, string charset]] )
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 ‘>’
复制代码
htmlentities() 函数把字符转换为 HTML 实体。
htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体。预定义的字符是:
- & (和号) 成为 &
- ” (双引号) 成为 "
- ‘ (单引号) 成为 '
- < (小于) 成为 <
- > (大于) 成为 >
复制代码
如果要执行,可以执行相反的函数,如下
html_entity_decode() 函数把 HTML 实体转换为字符。
html_entity_decode() 是 htmlentities() 的反函数。
htmlspecialchars_decode() 函数把一些预定义的 HTML 实体转换为字符。会被解码的 HTML 实体是:
- & 成为 & (和号)
- " 成为 ” (双引号)
- ' 成为 ‘ (单引号)
- < 成为 < (小于)
- > 成为 > (大于)
复制代码
3.strip_whitespace strip_tags
strip_tags() 函数剥去 HTML、XML 以及 PHP 的标签。
strip_whitespace() 函数返回已删除 PHP 注释以及空白字符的源代码文件。该函数对于检测脚本中的实际代码量很有用。
sleep() //让程序睡上一会,单位秒
usleep() //让程序睡上一会,单位微秒
similar_text() //计算字符串相似度 is_numeric – 检测变量是否为数字或数字字符串
|
上一篇: 1314学习网签到记录贴-2012年10月20日下一篇: 流畅配合 病为球队雪上加霜
|