Undefined offset: 1 in while loop when reading a file (PHP) [关闭]

问题描述 投票:0回答:0

我确实在其他地方看到过类似的答案,但似乎没有一个能完全符合我的问题。 当我运行这段代码时:

<?php
$i = 8536;
$x = 0;
while ($i < 33683) {
    echo '"' . file_get_contents("https://fake_url_because_i_dont_want_to_share_my_url_on_stackoverflow.com/page?episode=" . $i) . '", <br>';
    echo "<script>console.log('" . $i . " (episode: " . $x . ")')</script>";
    $i = $i + 1;
    $x = $x + 1;
}
?>

我得到这个错误:

Notice: Undefined offset: 1 in /home/u508075678/domains/kendasi.com/public_html/ai/crawler2.php on line 4

我不确定这是文件读取,还是 while 循环本身,但我们将不胜感激。谢谢!

php while-loop file-get-contents
© www.soinside.com 2019 - 2024. All rights reserved.