0

これが PHP の問題なのか APACHE の問題なのかはわかりませんが、スクリプトがまだ実行されている場合でも結果の一部を出力したかったのです。

つまり、私の for ループは長いスクリプトなので、その for ループで完成した結果の一部を出力したかったのです。しかし、何が起こるかというと、ページをロードするだけで何もエコーせず、スクリプトのロードが完了すると、すべてが一度に表示されます。

PSそれはwampを使用するときです...オンラインで自分のWebサイトにスクリプトをロードすると、結果の一部が出力され、スクリプトのロードが完了するまでさらに結果が追加されます。

4

2 に答える 2

1

出力バッファリングをオンにしている場合は、

ini_set("implicit_flush", "1");

スクリプトの最初でオフにすると、これはスクリプトが含まれているスクリプトにのみ影響します。php.iniで
設定されたサイト全体でオフにしたい場合は、.htaccessファイルでも実行できます。output_buffering = Off

于 2012-05-22T00:42:07.927 に答える
0

Do all the long work in the separate scripts and use AJAX to load the needed content, you may also break the loading part into pieces. jQuery.get is an easiest way to start http://api.jquery.com/jQuery.get/

The example code will load the data into the element having id=result (of course you need to include jQuery http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery)

$.get('long_script.php', function(data) {
  $('#result').html(data);
});

Of course, this is a bit harder then just echoing the results in the loop, but this is guaranteed to work on any server/browser setup and also the whole page is loaded during the long task, not anyhow limiting you in html/css usage

于 2012-05-22T00:27:46.593 に答える