php Echo /打印多行字符串?

1 php multiline echo

我有一个php文件启动我的exe.exe执行cout并且文本以html格式打印,这一切都很好.直到我写"someline \n"; \n打破输出,我只看到最后一行.如何打印/回显其中包含多行的文本/字符串?

当前的粘贴已经注释掉,我的文本打印正常.它在控制台看起来很丑陋,当我用IE7查看源码时(虽然我主要用FF浏览),看起来很痛苦.这是我目前的php和cpp文件

<html>
<head>
</head>
<body>
<?php
echo( exec('c:/path/to/exe/launchMe.exe hey lol hi') );
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

CPP

#include <string>
#include <iostream>
#include <sstream>
using namespace std;

const string htmlLine(string s)
{
    s+= "<br />";
//  s += "\n";
    return s;
}

int main(int argc, char *argv[])
{
    stringstream s;
    s << argc;
    cout << htmlLine("woot") << htmlLine(s.str());
    for (int i=0; i<argc; ++i)
    {
        s.str("");
        s << i << " = " << argv[i];
        cout << htmlLine(s.str());
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Jer*_*ten 5

来自http://php.net/exec:

返回值

命令结果的最后一行.如果您需要执行命令并将命令中的所有数据直接传回而没有任何干扰,请使用passthru()函数.

执行exec()函数只返回输出中的最后一行,但中继()返回所有输出.