1

I have a PHP file with the following contents:

1. <?php
2. $string = 'Hello world!';
3. echo $string;
4. ?>

I put a break on line 2 and line 4. I run the debugger. The browser output opens, the script has halted on line 2, and the browser output is empty. Makes sense! Then I jump to the next breakpoint at line 4, after the echo command. AT THIS POINT, should the browser update and display 'Hello world'? Or do debuggers not update the browser output step-by-step, and thus are NOT useful for browser display and are only useful for inspecting the inner-code itself?

Thank you!

4

1 回答 1

0

这里的答案有点复杂。一般来说,Xdebug 不会停止输出到浏览器,PHP 也不会这样做,除非你打开了输出缓冲或自动压缩。

但是,Web 服务器可能会在将数据发送到浏览器之前将数据缓冲到某个点。您可以通过调用 flush() 来强制 Web 服务器刷新其缓冲区:http: //php.net/flush。请注意,尽管某些浏览器也会等到它们有足够的数据来实际显示任何内容。

于 2013-06-23T09:24:59.527 回答