When was PHP behavior about this changed?
From which PHP version is it?
Warning: file_get_contents(): stream does not support seeking in /simple_html_dom.php
Warning: file_get_contents(): Failed to seek to position -1 in the stream in /simple_html_dom.php
include('parser/simple_html_dom.php');
$url = "https://en.wikipedia.org/wiki/Stack_Overflow";
$html = file_get_html($url);
if ($html !== false) {
foreach($html->find('div#mw-content-text') as $item){
$item->plaintext;
}
}
Others have shared the solution, but no one has shared why. I don't know specifically why this is different between PHP 7.0 & 7.1, but the PHP.net docs for this function say:
I can confirm that removing the offset parameter in
file_get_contents
on line 75 works for me and/or setting the offset to 0 in thefile_get_html
function on line 70 works too.I guess that the offset parameter was never meant to be used with non local files since:
Hope this helps clear up any confusion. With external sources, it makes sense to start streaming from the beginning.