簡體   English   中英

PHP的回聲/打印多行字符串?

[英]php Echo/printing a multiline string?

我有一個啟動我的exe的php文件。 該exe文件cout,並且文本以html打印,一切都很好。 直到我寫下“ someline \\ n”; \\ n中斷輸出,我只看到最后一行。 如何打印/回顯包含多行的文本/字符串?

當前的粘貼內容已被\\ n注釋掉,並且我的文本可以正常打印。 它在控制台中看起來很丑陋,當我使用IE7查看源代碼時(盡管我主要使用FF瀏覽),但查看源代碼卻很麻煩。 這是我當前的php和cpp文件

<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()返回所有輸出。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM