我不知道这是不是可能。我的需求是这样的:
<?php
$str=<<<abc
$sql=mysql_query("select * from links where column='value'");
$sq1=mysql_fetch_row($sql);
$s1=$rec[13];
$s2='Done';
if($s1==$s2) {
<form name=f1 method=post action=\"xxx.php\">
<input type=hidden name=income value=$rec[value]>
<input type=submit value=\"Accept\" id=submit2 name=submit2 disabled=\"disabled\">
</form>
}
else
<form name=f1 method=post action=\"xxx.php\">
<input type=hidden name=uname value=$rec[value]>
<input type=submit value=\"Accept\" id=submit2 name=submit2 ">
</form>
abc;
?>我不知道上面的格式是否正确。请推荐可支持的格式。
在上述格式中,我习惯于将PHP+HTML脚本存储到str变量中。我听说过htmlentities()和htmlspecialcharecters()函数,但我不知道如何使用它们。
如果插入了值,将使用mysql_fetch_row()从前端访问这些值,以显示这些插入的值。
如果以上是可以支持的建议我与良好的例子。如果不是,则建议将PHP+HTML脚本存储到变量中。
MySQL支持这种类型的查询。
帮助任何人
非常感谢。
发布于 2013-11-29 21:34:38
在您的示例中,您使用的是heredoc语法,其功能类似于双引号字符串。这意味着内容中的变量被展开了。
从PHP5.3开始,您可以使用nowdoc语法,它是
对于单引号字符串就像heredoc对于双引号字符串一样
此示例演示此语法的用法:
$name = 'MyName';
$str = <<<'EOT'
My name is "$name".
EOT;
echo $str;这将输出
我的名字是"$name“。
对插入$str查询进行清理后,可以将SQL的内容存储到适当的数据库字段中。
发布于 2013-11-29 21:38:35
我不得不同意上面的评论。你应该NOT这样做。但是,您的代码中有几个问题:
else提交”按钮上,您在末尾有一个不应该存在的"。",没有echo调用。<代码>F216
下面是“正确”的代码:
<?php
$str=<<<abc
$sql=mysql_query("select * from links where column='value'");
$sq1=mysql_fetch_row($sql);
$s1=$rec[13];
$s2='Done';
if($s1==$s2)
{
echo "
<form name=f1 method=post action=\"xxx.php\">
<input type=hidden name=income value=$rec[value]>
<input type=submit value=\"Accept\" id=submit2 name=submit2 disabled=\"disabled\">
</form>
";
}
else
echo "
<form name=f1 method=post action=\"xxx.php\">
<input type=hidden name=uname value=$rec[value]>
<input type=submit value=\"Accept\" id=submit2 name=submit2 />
</form>";
abc
;
echo $str;希望这能有所帮助。
https://stackoverflow.com/questions/20286885
复制相似问题