我想将此表导出为变量
$tbl=<<<EOT
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="3">$res=mysql_query($sql);<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOT;
但以下代码显示为文字!!
=mysql_query();
答案 0 :(得分:1)
您无法在EOT区域内使用功能 您必须在其外部定义一个变量才能在EOT块中使用它:
$res = mysql_query($sql);
$tbl=<<<EOT
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="3">$res<br/>COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br/>text line<br/>text line<br/>text line<br/>text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOT;