下面这个html字符串,如何用php的echo
或print
来输出?
<td width=275><input type="text" name="title" value="<?php echo $row['title']; ?>"></td>
echo "<td width=275><input type="text" name="title" value="<?php echo $row['title']; ?>"></td>"
不可以
echo '<td width=275><input type="text" name="title" value="<?php echo $row['title']; ?>"></td>'
也不可以
print <<<EOT
<td width=275><input type="text" name="title" value="<?php echo $row['title']; ?>"></td>
EOT;
也不可以,应为,这段html还包含php语句。
我的真实需求是
<?php
if(isset($_POST['flag'])
{
print <<<EOT
<td width=275><input type="text" name="title" value="<?php echo $row['title']; ?>"></td>
EOT;
else
{
}
?>
2种实现方式
1.把html代码直接写在页面,与php标签分开
2.html采用PHP的字符串内赋值
1并不是不能满足你需求