PHP: flush()?

cooliojazz

New Member
Prime Account
Messages
27
Reaction score
0
Points
1
Is there some setting that needs to be changed for flush to work here? I can't seem to get it to work, though I've seen hints that certain php settings might need to be changed... I'm just doing
PHP:
      echo "Some text";
      ob_flush();
      flush();
which does nothing. Help would be appreciated, because if I can't use flush, I guess I'll have to think of some other way. It's just I came to the conclusion this would be optimal earlier today and would love to use it if possible. Thanks! =)
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
try:

PHP:
<?php
error_reporting(E_ALL);
echo "Some text";
ob_flush();
flush();
 

cooliojazz

New Member
Prime Account
Messages
27
Reaction score
0
Points
1
No errors are reported, it just won't show up. And I've tried this in two different browsers and both direct and through an xmlhttp request, all with the same result =\
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
PHP:
<?php




$stuff = <<<END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Flush test </title>
</head>
<body>
HI. <br/>                                                                                                                                               
END;

$stuff  =  $stuff . date('h:i:s') . "<br />";

$stuff = str_pad( $stuff , 3900 ) ;

echo $stuff ;

flush() ;

sleep( 5 ) ;

echo date('h:i:s') . "<br />\n";

echo  <<<END
</body>
</html>

END;
?>

Seems like the output has to be a certain size before flush() will work on this setup.

Trial and error got padding the output to 3900 works.
 

cooliojazz

New Member
Prime Account
Messages
27
Reaction score
0
Points
1
Thank you very much! Exactly what I needed! =D Odd number to be required though... =P
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The apparent failure of flush could be a result of buffering on the load balancing proxy.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
@rafiq009: if you're not adding anything to the discussion, don't post. I'd say read the post on over-helping, but you're not even doing that.

Edit by Sharky: The message that this post refers to has been deleted
 
Last edited by a moderator:
Top