Ho un semplice script che dovrebbe leggere da un sito:
Codice PHP:
//Leggiamo il contenuto del sito
$handle = fopen("http://www.example.it/index.html", 'r');
//Legge solo 4096 bytes partendo da un offset di 4096 bytes
$data = stream_get_contents($handle, 4096, 4096)
//Chiude lo stream
fclose($handle);
La signature di stream_get_contents è:
string stream_get_contents ( resource handle [, int maxlength [, int offset]] )
Ma quando vado ad eseguire mi da il seguente errore:
codice:
Warning: stream_get_contents() [function.stream-get-contents]: stream does not support seeking in C:\wamp\www\videogames\include\test.php on line 23
Warning: stream_get_contents() [function.stream-get-contents]: Failed to seek to position 4096 in the stream. in C:\wamp\www\videogames\include\test.php on line 23
Invece provando ad eseguire degli esempi trovati su internet funziona tutto bene, ad esempio:
Codice PHP:
if ($stream = fopen('http://www.example.com', 'r')) {
// print all the page starting at the offset 10
echo stream_get_contents($stream, -1, 10);
fclose($stream);
}
Non riesco a capire dove sbaglio