Home > Backend Development > PHP Tutorial > 怎么判断字符串中是否含html代码

怎么判断字符串中是否含html代码

WBOY
Release: 2016-06-13 13:20:27
Original
1088 people have browsed it

如何判断字符串中是否含html代码?
如何判断字符串中是否含html代码?求高效准确代码

------解决方案--------------------


$str="

x";
if (strip_tags($str) != $str) {
 echo "has html tags";
} else { echo "not have";}
?>
------解决方案--------------------
遵循标准的写法,只需查找是否存在 "" 就行了,没什么高效准确!用正则就可以

------解决方案--------------------
3楼的说法不同意,存在也不一定存在HTML标记

但是我也不晓得有什么高效率的办法,关注!
------解决方案--------------------
查找" 

原则上,如果html中有非html的 ,应该转为实体的

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template