
$str
=
'<html><head>this
is
head</head><body>this
is
body</body></html>'
echo
strip_tags($str)
结果:this
is
head
this
is
body
一般用:strip_tags()函数来脱掉html或php的标签。
注意:因为strip_tags()【不】怎么验证【标签的完整性】,也就是意味着,当【html标签损坏时】有可能导致脱掉更多的文本内容。
手机屏幕出现html的清除方法是调用正则表达式清理html标签。1、显示的html代码如下:
<table style="width: 300pxtext-align: center" border="1" cellpadding="5"><tr><th width="75"><strong>Name</strong></th><th colspan="2"><span style="font-weight: bold">Telephone</span></th></tr><tr><td>John</td><td><a href="tel:0123456785">0123 456 785</a></td><td><img src="images/check.gif" alt="checked" /></td></tr></table>
2、开始用js的正则表达式清除
stringWithHTML = stringWithHTML.replace(/<\/?[a-z][a-z0-9]*[^<>]*>/ig, "")
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)