我正在嘗試獲取當前頁面中存在的圖像數量。我剛剛找到了一個 JS 方法,但我想通過 php 找到一個方法。我如何通過 PHP 獲得該腳本的相同結果?function myFunction() {
var x = document.images.length;
document.getElementById("demo").innerHTML = x;
}
1 回答

米琪卡哇伊
TA貢獻1998條經驗 獲得超6個贊
嘗試這個:
<?PHP
$code= file_get_contents($url); //this line is getting HTML code from the website
echo substr_count($code, '<img');
?>
- 1 回答
- 0 關注
- 136 瀏覽
添加回答
舉報
0/150
提交
取消