php - 页面上的图像计数器
问题描述
我正在尝试获取当前页面中存在的图像数量。我刚刚找到了一个 JS 方法,但我想通过 php 找到一个方法。如何通过 PHP 获得与此脚本相同的结果?
function myFunction() {
var x = document.images.length;
document.getElementById("demo").innerHTML = x;
}
解决方案
尝试这个:
<?PHP
$code= file_get_contents($url); //this line is getting HTML code from the website
echo substr_count($code, '<img');
?>
推荐阅读
- python - Python Flask HTML 路由参数
- javascript - 如何在没有 jqueryUI 的情况下使 div 垂直可拖动
- python - 使用 tensorflow 插件图像转换时出现未定义符号错误
- haskell - 这个 Functor 组合器有名字吗?
- c - 如何将二维数组作为参数传递?
- python - 在numpy数组python中的每个元素之后添加元素
- groovy - 为什么不允许隐式调用内部类实例?
- multithreading - 为什么一个进程在双核机器上使用两倍多的 CPU 资源?
- reactjs - 将类组件转换为函数组件
- android - Play商店上的PWA2APK仍然在顶部显示网址栏