Stream=fopen ("xxx.html"); var str = "; while (!feof (stream) { size+=1024; Str.=fread (stream,size);} ....
STR can only get 1024 bytes, the back is more than truncated, but Fread did read, is not used. = Is there a problem, or is there a special character in the HTML that causes truncation?
Thank you, great God.
Reply to discussion (solution)
$stream =fopen ("Test.txt", "A +"), $str = "; $size =1024;while (!feof ($stream)) {$str. =fread ($stream, $size);} Fclose ($stream); Echo $str;
$stream =fopen ("Test.txt", "A +"), $str = "; $size =1024;while (!feof ($stream)) {$str. =fread ($stream, $size);} Fclose ($stream); Echo $str;
I read the HTML, with the read mode should be OK, some pages can be crawled, some page crawl is truncated, doubt an HTML tag problem? Thank you
As far as the code above is concerned, you can't run it, maybe you wrote it wrong.
As for some special character of the HTML you said, it should not exist.
And you just read an HTML, the data is not big, it is recommended to use file_get_contents (), better performance than fread
You're not the PHP code.
As far as the code above is concerned, you can't run it, maybe you wrote it wrong.
As for some special character of the HTML you said, it should not exist.
And you just read an HTML, the data is not big, it is recommended to use file_get_contents (), better performance than fread
Well, I wrote, probably meaning, just started to change the cms,php entry level.
You write very right, but I do encounter problems, debugging, every time while inside the fread can read the data, but, added to the string str inside, the length of STR changed, but the content of each increase, is debugging the problem, debugging can only show the variable part? I changed the xdebug display maximum length, no effect, I use the vs.php debugging, how to show all. How can you see how much str has been saved, see the length of its increase, not seen the content changes
You use
$stream =fopen ("test.html", "R"); $str = "; $size =1024;while (!feof ($stream)) {$tmp =fread ($stream, $size); file_put_ Contents (' D:/log.log ', $tmp. Php_eol,file_append); $str. = $tmp; $tmp = ";} Fclose ($stream); Echo $str;
Run the program, and then open Log.log view, each row is the data read by each while loop
What code are you? C?
You use
$stream =fopen ("test.html", "R"); $str = "; $size =1024;while (!feof ($stream)) {$tmp =fread ($stream, $size); file_put_ Contents (' D:/log.log ', $tmp. Php_eol,file_append); $str. = $tmp; $tmp = ";} Fclose ($stream); Echo $str;
Run the program, and then open Log.log view, each row is the data read by each while loop
Okay, I'll try, good man.