简体   繁体   中英

how can i show one statements to print in 3 lines using single echo statement?

Here is my code

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

Here it have to print like this.....

Current Timesheet period

$startdate (Mon) ~ $enddate (Sun) of $pcode

has been successfully Updated....!

There are two way the most popular is to use \\n at the end of your echo to break line. Or you could use
tag which is less efficient as it will add markup to you page.

An example would be

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

this will out put

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

And here is the fiddle

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM