php回声/打印多行字符串


php Echo/printing a multiline string?

我有一个启动exe的php文件。exe执行cout,文本以html打印,这一切都很好。直到我写"someline''n";中断输出,我只看到最后一行。如何打印/echo文本/包含多行的字符串?

当前粘贴已被注释掉,我的文本打印良好。它在控制台中看起来很难看,当我用IE7查看源代码时(尽管我主要用FF浏览),它看起来很痛苦

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

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;
}

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

返回值

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

exec()函数只返回输出的最后一行,但passthru()返回所有输出。