htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体。
解决方案 »
- service network restart 出现乱码
- 请教php读取word内容到相应的文本框内?
- 关于PHP FOPEN的简单问题!
- php面向对象的问题
- 如何能使首页的窗口大小为固定的宽度值,而且用鼠标拖动不会改变大小 呢?
- 首次在csdn上被人恶评,发帖散分。
- (顶者有分)富客户端网站应用,请大家帮顶且测试下!
- 谁给修改一下 让这个缩略图函数支持bmp文件
- php连接mongoDB
- 经过几天的努力终于将php版的eWebEditor(网页在线编辑器)给改出来啦。用得着的兄弟都进来顶一下
- 怎么样把URL路径模式的地址 传给<a></a>中的href 让他执行一个controlled类中的方法...
- php snmp问题,达人请进
htmlspecialchars只转换 &、""、'、<、>'&' (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 '>'
function html2txt($document){
$search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA
);
$text = preg_replace($search, '', $document);
return $text;
}
$act=html2txt($_POST['act']);
$title=html2txt($_POST['title']);
$content=html2txt($_POST['content']);
?> 这个足够强大了
输出的时候用 stripcslashes
试一下。