php的转义

1.addslashes()

该函数会在预定义字符("、'、\)前加个\,并且php会自动在通过get,post,cookie得到的数据中运用此函数,因此不需要重复饮用此函数;在php5.4版本以后,get_magic_quotes_gpc()始终返回false,为了防止重复添加\,也可以使用该函数检测一下。

2.htmlspecialchars()

该函数会把预定义字符("、'、&、<、>)转为html实体,它的解函数是htmlspecialchars_decode()。

3.htmlentities()

默认只转换双引号

猜你喜欢

转载自blog.csdn.net/weixin_41111189/article/details/82996714