从php向shell输出新行最好的方法是什么?


What is the best way to output new lines to the shell from php?

我喜欢在PHP脚本运行时向shell输出大量细节。

我有很多这样的行:

echo "'n'n" . __method__ . " - PDF file does not exist.";

我的代码中到处都有这么多的'n,这让我很恼火。有更好的方法吗?也许是我漏掉了什么简单的东西?

在一些主要的php库中有哪些首选方法?

PHP中没有标准方法

但是你可以写一个函数来做....

function shellprint($string)
{
    echo($string . "'n");
}

我已经测试了这种方法和其他方法,但没有一种有效。

生锈的的工作方式是有类似 的东西
        if ($something==true)
        {
             echo 'Hello
This is a new line.
and this another new line';
        }

我想在我的代码中有一个漂亮的缩进样式,所以我创建了一个小函数来解决这个问题。

function shecho($text) {
    $text = str_replace(''n', '
', $text);
    echo $text; 
}

这样我只需要写

shecho ('Hello'nThis is a new line.'nand this another new line');

简单的东西。
希望对大家有所帮助!