如何使用单个echo语句显示一行语句在3行中打印?

时间:2013-06-13 08:56:34

标签: php javascript

这是我的代码

PHP

<?php
    $count1 = $obj->getDatef();
    $as1 = $count1 + 6;
    $startdate = date('d/m/Y', strtotime($count1 . ' days'));
    $enddate = date('d/m/Y', strtotime($as1 . ' days'));

    echo "<script type='text/javascript'>";
    echo "alert('Current Timesheet period($startdate (Mon) ~ $enddate (Sun)) of 
              $pcode has been successfully Updated....!')";
    echo "</script>";
    echo "<script type='text/javascript'>";
    echo "window.location='my_tm.php'";
    echo "</script>";
?>

这里必须像这样打印.....

  

当前时间表期间

     

$ startdate(Mon)〜$ enddate(Sun)$ pcode

     

已成功更新....!

3 个答案:

答案 0 :(得分:0)

最常用的两种方法是在你的回声结束时使用\ n来断行。或者您可以使用效率较低的标签,因为它会为您的页面添加标记。

一个例子是

echo("im line one \n im line two\n im line three");

这将出局

im line one
im line two
im line three

答案 1 :(得分:0)

echo "alert('Current Timesheet period\n
             $startdate (Mon) ~ $enddate (Sun) of $pcode\n
             has been successfully Updated....!')";

And here is the fiddle

答案 2 :(得分:0)

echo "alert('Current Timesheet period\n$startdate (Mon) ~ $enddate (Sun) of $pcode\n has been successfully Updated....!')";