我不知道如何在PHP中回显一个新行。我尝试了echo "\n"
,但它不起作用。
我想在以下代码中回显新行。
代码:
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime.
"CurrentTime: ".$CurrentTime.
"after ".($fLifeTime)." Days from Creation: ".$fAge;
}
答案 0 :(得分:8)
如果您要从浏览器查看此输出,则必须使用<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;
}
答案 1 :(得分:1)
你可以这样做
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime.
"<br />CurrentTime: ".$CurrentTime.
"<br />after ".($fLifeTime)." Days from Creation: ".$fAge;
}
答案 2 :(得分:0)
尝试这样做: -
if (file_exists($fName)) {
echo "CreationTime: ".$CreationTime.
"CurrentTime: ".$CurrentTime.
"after ".($fLifeTime)." Days from Creation: ".$fAge;
echo "<br/>"; //break to new line.
}
答案 3 :(得分:0)