2013-06-13 31 views
0

這裏是我的代碼如何顯示一條語句以使用單個回顯語句在3行中打印?

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>"; 
?> 

這必須打印這樣.....

當前時間表階段

$開始日期(週一)〜$ enddate(Sun)$ pcode

已成功更新....!

+0

使用'\ N'突破語句插入新行。 – Rikesh

+0

可能重複的[在JavaScript警告框中的新行](http://stackoverflow.com/questions/1841452/new-line-in-javascript-alert-box) – Rikesh

+0

好於使用它。 – Rikesh

回答

0

最流行的方法有兩種,在您的回聲結束時使用\ n來分界線。或者,您可以使用
標記,因爲它會將標記添加到您的頁面,所以效率較低。

一個例子是

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

這將出來把

im line one 
im line two 
im line three 
+0

單個回聲陳述.... – liyakat

+0

糾正我的壞衝到它 –

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

And here is the fiddle

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