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.

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

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀