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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.