htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体。
解决方案 »
- 怎么反驳此类客户,是我的错吗?
- 【求助】PHP的Switch语句case无法选择
- 蔡鸟求救usort函数 php手册上的这个函数的例子我看不懂 请前辈们告诉我他是如何运行的
- 字符串转数组的问题,请求帮助
- 为什么正则表达式通不过???
- php 把网页内容转为 excel,如何保持显示格式不变........
- 我想问问!!$符号代表什么??为有些前面有,有些没有??
- 请教一下各位,数据库从MYSQL转到SQLserver要注意些什么?
- 非常着急,大家帮帮我!!!!!
- 如何实现一个页面控制器
- 怎么样把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
试一下。