如何在php变量中存储html?

如何在php变量中存储html?,php,html,css,Php,Html,Css,我制作了一个php页面,我想将所有html存储在一个php变量中,然后使用ajax获取,我如何将此html存储在php变量名#msg中,以下是我的代码: $msg="<div id="new2" style="background:#fff; width:779px; min-height:310px;"> <table align="center" width="779px" cellpadding="0" cellspacing="

我制作了一个php页面,我想将所有html存储在一个php变量中,然后使用ajax获取,我如何将此html存储在php变量名#msg中,以下是我的代码:

  $msg="<div id="new2"  style="background:#fff; width:779px; min-height:310px;"> 
               <table align="center"  width="779px" cellpadding="0"  cellspacing="0" id="tb1">
                        <tr style="height:28px; font-size:12px;">
                          <td style="width:246px">Name</td>
                          <td style="width:145px">CITY</td> 
                          <td style="width:102px">ABCDEF</td>
                          <td style="width:71px">BUDGET</td> 
                          <td style="width:102px">MEMBERSHIP</td>
                          <td style="width:84px" id="td1">UNTIL</td>
                        </tr>
                        </table>
                     <?php
                     $color='#DADDE2';
                     $business=getbussinesspagination(0,$start,$per_page);
                        if ($business){
                            while ($row = $business->fetch_assoc ()){
                             if($color=='#DADDE2')
                                    $color='#F9F9F9';
                             else
                                    $color='#DADDE2';                            
                      ?>   
                          <div id="m1" style="width:246px; height:28px; background:<?php echo $color; ?>; float:left"><p style="padding-left:45px; margin-top:8px;"><?php echo ($row['title']); ?></p></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:<?php echo $color; ?>"><p style="padding-left:30px; margin-top:8px;"><?php echo ($row['cityName']); ?></p></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:<?php echo $color; ?>"><p style="padding-left:40px; margin-top:8px;"><?php if($row['article']!=''){ echo 'A';} if($row['event']!=''){echo 'E'; } ?></p></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:<?php echo $color; ?>"><p style="padding-left:25px; margin-top:8px;"><?php echo ($row['credit']); ?></p></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:<?php echo $color; ?>"><p style="padding-left:25px; margin-top:8px;"><?php echo ($row['name']); ?></p></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:<?php echo $color; ?>"><p style="padding-left:10px; margin-top:8px;"><?php echo ($row['renewal_date']); ?></p></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:<?php echo $color; ?>"><img src="messg.png" style="margin:8px 0 0 2px;"></div> 
                        <?php 
                        }
                }

                        ?>  
                          <div id="m1" style="width:246px; height:28px; background:#DADDE2; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#F9F9F9; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#DADDE2; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#F9F9F9; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#DADDE2; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#F9F9F9; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#DADDE2; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#F9F9F9; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 

                          <div id="m1" style="width:246px; height:28px; background:#DADDE2; float:left"></div>
                          <div id="m2" style="width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m3" style="width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m4" style="width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m5" style="width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div>  
                          <div id="m6" style="width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"></div> 
                          <div id="m7" style="width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;"><img src="messg.png"  style="margin:8px 0 0 2px;"></div> 
                </div>
$msg=”
名称
城市
ABCDEF
预算
会员
直到

您应该使用语法。您可以复制整个HTML内容并将其传递到
herdoc
中。您的变量也将被解析

<?php
$str = <<<EOD
Example <b>of</b> string
spanning multiple lines
using heredoc <b>syntax</b>.
EOD;

echo $str;

您应该使用语法。您可以复制整个HTML内容并将其传递到
herdoc
中。您的变量也将被解析

<?php
$str = <<<EOD
Example <b>of</b> string
spanning multiple lines
using heredoc <b>syntax</b>.
EOD;

echo $str;

或在HTML代码中包含
时,只需在此处使用
,即可使用
包装HTML。仅当您仅在代码中使用
引号!

或仅在HTML代码中包含
时使用
$msg='此处的HTML

'
即可。只有当您在代码中使用“代码> > 引号!

< p>干净的方式是使用遗传语法,并修改您的代码如下,只使用中间的HTML(无函数调用)


VARYDUMP($Out1,$Out2);

< P> >使用遗传语法,并修改您的代码如下,只在HTML中间使用变量(无函数调用)


var_dump($out1,$out2);

没有heredoc您不能使用
没有heredoc您不能使用
,如果我没有遗漏任何内容:

<?php

$msg = "<div id=\"new2\"  style=\"background:#fff; width:779px; min-height:310px;\"> 
            <table align=\"center\"  width=\"779px\" cellpadding=\"0\"  cellspacing=\"0\" id=\"tb1\">
                <tr style=\"height:28px; font-size:12px;\">
                    <td style=\"width:246px\">Name</td>
                    <td style=\"width:145px\">CITY</td> 
                    <td style=\"width:102px\">ABCDEF</td>
                    <td style=\"width:71px\">BUDGET</td> 
                    <td style=\"width:102px\">MEMBERSHIP</td>
                    <td style=\"width:84px\" id=\"td1\">UNTIL</td>
                </tr>
            </table>";

$color='#DADDE2';

$business = getbussinesspagination(0,$start,$per_page);
if ($business)
{
    while ($row = $business->fetch_assoc ())
    {
        if($color=='#DADDE2')
            $color='#F9F9F9';
        else
            $color='#DADDE2';                            

        $msg .= "<div id=\"m1\" style=\"width:246px; height:28px; background:{$color}; float:left\"><p style=\"padding-left:45px; margin-top:8px;\">{$row['title']}</p></div>
        <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:30px; margin-top:8px;\">{$row['cityName']}</p></div> 
        <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:40px; margin-top:8px;\">".($row['article']!=''?'A':'').($row['event']!=''?'E':'')."</p></div> 
        <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:25px; margin-top:8px;\">{$row['credit']}</p></div> 
        <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:25px; margin-top:8px;\">{$row['name']}</p></div>  
        <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:10px; margin-top:8px;\">{$row['renewal_date']}</p></div> 
        <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><img src=\"messg.png\" style=\"margin:8px 0 0 2px;\"></div> ";
    }
}

$msg .= "<div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 
    </div>";

echo $msg;

?>

如果我没有错过任何东西:

<?php

$msg = "<div id=\"new2\"  style=\"background:#fff; width:779px; min-height:310px;\"> 
            <table align=\"center\"  width=\"779px\" cellpadding=\"0\"  cellspacing=\"0\" id=\"tb1\">
                <tr style=\"height:28px; font-size:12px;\">
                    <td style=\"width:246px\">Name</td>
                    <td style=\"width:145px\">CITY</td> 
                    <td style=\"width:102px\">ABCDEF</td>
                    <td style=\"width:71px\">BUDGET</td> 
                    <td style=\"width:102px\">MEMBERSHIP</td>
                    <td style=\"width:84px\" id=\"td1\">UNTIL</td>
                </tr>
            </table>";

$color='#DADDE2';

$business = getbussinesspagination(0,$start,$per_page);
if ($business)
{
    while ($row = $business->fetch_assoc ())
    {
        if($color=='#DADDE2')
            $color='#F9F9F9';
        else
            $color='#DADDE2';                            

        $msg .= "<div id=\"m1\" style=\"width:246px; height:28px; background:{$color}; float:left\"><p style=\"padding-left:45px; margin-top:8px;\">{$row['title']}</p></div>
        <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:30px; margin-top:8px;\">{$row['cityName']}</p></div> 
        <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:40px; margin-top:8px;\">".($row['article']!=''?'A':'').($row['event']!=''?'E':'')."</p></div> 
        <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:25px; margin-top:8px;\">{$row['credit']}</p></div> 
        <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:25px; margin-top:8px;\">{$row['name']}</p></div>  
        <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:10px; margin-top:8px;\">{$row['renewal_date']}</p></div> 
        <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><img src=\"messg.png\" style=\"margin:8px 0 0 2px;\"></div> ";
    }
}

$msg .= "<div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 
    </div>";

echo $msg;

?>

对于PHP中的这种模板,我使用ob_get_contents()


对于PHP中的这种模板,我使用ob_get_contents()


你看过脚本了吗?
$msg=“Quotes,Quotes,QUOTE你看过脚本了吗<代码>$msg=“Quotes,Quotes,Quotes当心,
EOD
结尾没有空格/任何字符前缀或附加。@vonUbisch,是的,手册中已经明确说明了所有内容,我已经链接了它。阅读它是最小的OP能做的。是的,但是他是在文本中间的if语句。注意,结尾<代码> EOD没有空白或任何字符准备或追加。@ VunuBichh,是的,所有的东西都在手册中明确地指定了,我已经链接了它。阅读是最不可能的。是的,但是他在课文中间是if语句。非常感谢Dainis Abolosthanks,非常感谢Dainis Abolos。
<?php

$msg = "<div id=\"new2\"  style=\"background:#fff; width:779px; min-height:310px;\"> 
            <table align=\"center\"  width=\"779px\" cellpadding=\"0\"  cellspacing=\"0\" id=\"tb1\">
                <tr style=\"height:28px; font-size:12px;\">
                    <td style=\"width:246px\">Name</td>
                    <td style=\"width:145px\">CITY</td> 
                    <td style=\"width:102px\">ABCDEF</td>
                    <td style=\"width:71px\">BUDGET</td> 
                    <td style=\"width:102px\">MEMBERSHIP</td>
                    <td style=\"width:84px\" id=\"td1\">UNTIL</td>
                </tr>
            </table>";

$color='#DADDE2';

$business = getbussinesspagination(0,$start,$per_page);
if ($business)
{
    while ($row = $business->fetch_assoc ())
    {
        if($color=='#DADDE2')
            $color='#F9F9F9';
        else
            $color='#DADDE2';                            

        $msg .= "<div id=\"m1\" style=\"width:246px; height:28px; background:{$color}; float:left\"><p style=\"padding-left:45px; margin-top:8px;\">{$row['title']}</p></div>
        <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:30px; margin-top:8px;\">{$row['cityName']}</p></div> 
        <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:40px; margin-top:8px;\">".($row['article']!=''?'A':'').($row['event']!=''?'E':'')."</p></div> 
        <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:25px; margin-top:8px;\">{$row['credit']}</p></div> 
        <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:25px; margin-top:8px;\">{$row['name']}</p></div>  
        <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><p style=\"padding-left:10px; margin-top:8px;\">{$row['renewal_date']}</p></div> 
        <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:{$color}\"><img src=\"messg.png\" style=\"margin:8px 0 0 2px;\"></div> ";
    }
}

$msg .= "<div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#F9F9F9; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#F9F9F9;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 

    <div id=\"m1\" style=\"width:246px; height:28px; background:#DADDE2; float:left\"></div>
    <div id=\"m2\" style=\"width:145px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m3\" style=\"width:101px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m4\" style=\"width:70px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m5\" style=\"width:99px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div>  
    <div id=\"m6\" style=\"width:84px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"></div> 
    <div id=\"m7\" style=\"width:23px;   height:28px; float:left; margin:0 0 0 1px;background:#DADDE2;\"><img src=\"messg.png\"  style=\"margin:8px 0 0 2px;\"></div> 
    </div>";

echo $msg;

?>
ob_end_clean();
ob_start();
include __DIR__ . '/your_template.php';
$contents = ob_get_contents();
ob_end_clean();