donglie9067 2010-08-16 20:50
浏览 85
已采纳

将XDebug与Aptana和fwrite一起使用时,无法显示多个输出行

When using Aptana with PHP 5.2.3 in debug mode (using thread safe XDebug 2.1.0 for PHP 5.2 VC6) to run a simple multi-line hello world script I get some erratic behaviour on the Aptana 'Console' tab.

I've a hello_world.php script that contains the following:

<?php
$stdout = fopen('php://stdout', 'w');
fwrite($stdout, 'Hello world!');
fwrite($stdout, 'Hello world!2');
fwrite($stdout, 'Hello world!3');
fclose($stdout);
?>

My PHP debug configuration in Aptana is using php.exe from the c:\wamp\php folder, in CLI mode with XDebug as the debugger.

If I start a debug session and let my code execute straight through, I get the expected output (as I do if I run this from a command prompt).

If I step through the code however, I only see the first line ("Hello world!") in the "Console" section of Aptana. In fact, I can avoid even seeing the first "Hello world!" by stepping quickly from the fopen() line to the first fwrite() line. If I pause for perhaps 3 to 5 seconds after stepping through the fopen(), and then run the fwrite, I will get the first "Hello world!".

Needless to say, this is completely baffling. Please let me know if you'd like more information about my configuration, and I'll be glad to provide it!

Cheers! Duncan

(I'm actually attempting to debug a CakePHP shell script that uses fwrite to stdout instead of echo... but I want to solve this problem first!)

  • 写回答

1条回答 默认 最新

  • doudeng3008 2010-08-17 15:42
    关注

    I've found that the following does work (thanks to the first comment):

    $fp = fopen('php://output', 'w'); // Note, not: php://stdout
    fwrite($fp, 'Hello world!');
    flush();
    fwrite($fp, 'Hello world!2');
    flush();
    fwrite($fp, 'Hello world!3');
    flush();
    fclose($fp);
    
    ?>
    

    This still isn't appearing the 'Console' tab in Aptana (Eclipse), just in the 'Debug Output' tab, but I do at least have output. The script is also accepting arguments now, which it wasn't doing before.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?