Jump to content

fsockopen remove buffer size.


Recommended Posts

I have this inside of a method:

if($output){
$opt = fread($pointer, 10000);
if(!$headers){
	$opt = preg_replace("/http.+(\r\n\r\n|\n\n|\r\r)/isU", "", $opt);
}
echo $opt;
}

 

one of my methods uses fsocketopen to open a file and start processing it. I then have this method which reads out the data to the page. as the file is being processed.

 

Here is the file that is being processed

<?php
function flush_buffers(){
    ob_end_flush();
    flush();
    ob_start();
}
for($i=0;$i<10;$i++){
echo "Test1: $i";
flush_buffers();
usleep(500000);
}
?>

 

when http outputs the data it also outputs the buffer size as well. I ran it on two files, and here was my output:

 

Test1: cats
b
Test1: cats
b
Test1: cats
b
Test1: cats
b
Test1: cats
b
Test1: cats
b
Test1: cats
b
Test1: cats
b
Test1: cats
b
Test1: cats
0

Test2: 0
8
Test2: 1
8
Test2: 2
8
Test2: 3
8
Test2: 4
8
Test2: 5
8
Test2: 6
8
Test2: 7
8
Test2: 8
8
Test2: 9

 

Is there any way to remove the buffer size (the "8" and the "b")?

I basically went off of this and converted it to a class: http://phplens.com/phpeverywhere/?q=node/view/254

Link to comment
https://forums.phpfreaks.com/topic/235787-fsockopen-remove-buffer-size/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.