如何使用 php 检查是否存在特定的嵌入到 html 页面中的代码
How to check the presence of a specific embbeded code into an html page using php?
我有一个简单的问题,无法管理一个简单的在线检查,我们的客户在他们的网站页面上的代码存在。例如,他们必须包含像这样的html代码:
<div class="Aclass">
<div data-tag="123456" class="Mandatory Mandatory-test></div>
<div class="Mandatory Mandatory-dialog">
<div class="Mandatory Mandatory-test2"></div>
</div>
<script type="text/mustache" name="landing/Execute">
<a data-tag="Execute-test">Manage</a>
</script>
</div>
我希望能够知道代码是否通过像 cron 这样的定时检查正确存储在网站中。
谢谢你的帮助
您可以使用
stripos()
,如果在用户的HTML页面中找不到此字符串,它将返回false。看来:
$code = "<div class='"Aclass'">
<div data-tag='"123456'" class='"Mandatory Mandatory-test'"></div>
<div class='"Mandatory Mandatory-dialog'">
<div class='"Mandatory Mandatory-test2'"></div>'n </div>'n <script type='"text/mustache'" name='"landing/Execute'">'n <a data-tag='"Execute-test'">Manage</a>'n </script>'n</div>";
if(!stripos($codeOfPage,$code)){
// Your code isn't present in the page
}
相关文章:
- 如何解析结构不良的 html 代码
- 我的html表单无法验证.请参阅代码片段中的html代码和java脚本
- 将第一个字母大写并去掉html代码
- 我在下拉列表中尝试了下一个和前五年的html代码.接下来的5年我都过得很好.我怎样才能拿到之前的5年
- 使用.format在一些HTML代码中插入文本,会出现错误(Python)
- html代码没有在记事本++上运行
- 来自mysql的动态值用于html代码点火器视图中的图形
- 如何:编写漂亮的HTML代码和Javascript控制台
- 我需要java代码来打开html代码onclick事件
- html代码需要可点击的文本按钮
- 是否可以在JavaScript中包含HTML代码
- 如果javascript打开/关闭,则隐藏和显示html代码
- 使用PartialView作为带有变量的可重悬浮html代码
- 在jquery中复制特定的html代码
- 如何在AngularJS的上下文中使用Google Chrome Developer Tool在HTML代码中设置断点
- 显示HTML代码块
- 从HTML代码中提取数据
- 如何获取保存在变量中的HTML代码的任何属性的值
- 将html代码转换为十六进制
- JavaScript和Html代码来运行所有类型的视频并获取状态