我不知道如何在 PHP 中回显一个新行。我已经尝试过echo "\n"
,但它不起作用。
我想在下面的代码中回显新行。
代码:
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime.
"CurrentTime: ".$CurrentTime.
"after ".($fLifeTime)." Days from Creation: ".$fAge;
}
我不知道如何在 PHP 中回显一个新行。我已经尝试过echo "\n"
,但它不起作用。
我想在下面的代码中回显新行。
代码:
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime.
"CurrentTime: ".$CurrentTime.
"after ".($fLifeTime)." Days from Creation: ".$fAge;
}
如果您正在从浏览器查看此输出,则必须使用<br />
标记或放在<pre>
回显之前。
对于新行
示例。
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime. "<br />".
"CurrentTime: ".$CurrentTime. "<br />" .
"after ".($fLifeTime)." Days from Creation: ".$fAge;
}
前例
if (file_exists($fName)) {
echo "<pre>";
echo "CreationTime: ".$CreationTime. PHP_EOL .
"CurrentTime: ".$CurrentTime. PHP_EOL .
"after ".($fLifeTime)." Days from Creation: ".$fAge;
}
你可以这样做
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime.
"<br />CurrentTime: ".$CurrentTime.
"<br />after ".($fLifeTime)." Days from Creation: ".$fAge;
}
尝试这样做:-
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime.
"CurrentTime: ".$CurrentTime.
"after ".($fLifeTime)." Days from Creation: ".$fAge;
echo "<br/>"; //break to new line.
}