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.

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

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行