使用PHP将HTML刷新到浏览器

I am trying to implement the trick listed on this page http://developer.yahoo.com/performance/rules.html#flush "Flush the Buffer Early".

Everytime I try to run this thing I am not getting the desired output.

I have written the following code.

<html>
<head>
    <title>This is title</title>
    <script type="text/javascript" src="/1.js"></script>
    <link rel="stylesheet" type="text/css" href="/1.css">
</head>

<body>
ABC
<?php
flush();
sleep(3);
?>
</body>
</html>

The result enter image description here

I am getting the same result on both Firefox and Chrome.

What I expect is that the download of CSS and JS files should start immediately, and not wait for 3 seconds.

Based on the information given on the internet, I have tried the following things but nothing has helped.

1. ob_start(); and then ob_flush();

2. Using both ob_flush(); and flush(); ( in both the orders )

3. Adding the thing like this
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);

4. Putting more content in body 4~5 KB of content before flush.

5. And many other things.

I doubt if achieving this kind of thing is actually possible.

Hum... In yahoo's document, flush() was after </head> and before <body>.

  ... <!-- css, js -->
</head>
<?php flush(); ?>
<body>
  ... <!-- content -->

In your code, It's inside <body>. Did you tried to put the php code before it?

Hi I faced the same situation it ob_start and ob_flush by itself did not work for me too.

so after editing the code it worked EDIT::

<?php 
if (ob_get_level() == 0) ob_start();
for($i = 0 ; $i < 10 ; $i++){

echo $i . '<br>';
sleep(1);
    echo str_pad('',4096) ;   
    ob_flush();
    flush();

}
?>