从php向shell输出新行的最佳方式是什么?

从php向shell输出新行的最佳方式是什么?,php,shell,comments,Php,Shell,Comments,当我的PHP脚本运行时,我喜欢向shell输出很多细节 我有很多这样的台词: echo "\n\n" . __method__ . " - PDF file does not exist."; 我的代码中到处都是\ns,这让我非常恼火。有更好的方法吗?也许有什么简单的东西我遗漏了 在一些主要的php库中,有哪些首选方法可以做到这一点?在php中没有标准方法 但是你可以写一个函数来实现这一点 function shellprint($string) { echo($string . "\

当我的PHP脚本运行时,我喜欢向shell输出很多细节

我有很多这样的台词:

echo "\n\n" . __method__ . " - PDF file does not exist.";
我的代码中到处都是
\n
s,这让我非常恼火。有更好的方法吗?也许有什么简单的东西我遗漏了


在一些主要的php库中,有哪些首选方法可以做到这一点?

在php中没有标准方法

但是你可以写一个函数来实现这一点

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

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');
简单的东西。

希望它能帮助任何人

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

锈迹斑斑的工作方式是

        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');
简单的东西。

希望它能帮助任何人

您可以编写某种
writeln()
函数来抑制这些新行。您可以编写某种
writeln()
函数来抑制这些新行。