Php 是否可以在if语句中使用heredoc?
在php中的if语句中使用heredoc进行编码是否可能,是否正确Php 是否可以在if语句中使用heredoc?,php,Php,在php中的if语句中使用heredoc进行编码是否可能,是否正确 if($selection!='') { $price=getselection($selection,$getprice[$selection]); if ($selection<8) { print 'Please enter the amount<br />'; print '<form action="" method="post">
if($selection!='')
{
$price=getselection($selection,$getprice[$selection]);
if ($selection<8)
{
print 'Please enter the amount<br />';
print '<form action="" method="post"><input type="text" name="money1" value="'.$money1.'">';
print '<input type="text" name="money2" value="'.$money2.'">';
print '<input type="text" name="money3" value="'.$money3.'"><input type="submit">';
print '<input type="hidden" name="selection" value="'.$selection.'"';
print '</form><br>';
if (($money1!='')&&($money2!='')&&($money3!==''))
{
$total=$money1+$money2+$money3;
$money=getmoney($total);
$change=getchange($total,$price);
}
}
}
echo '</pre>';
if($selection!='')
{
$price=getselection($selection,$getprice[$selection]);
如果是这样的话
if (conditional)
{
$foo = <<<html
<tag></tag>
<tag></tag>
<tag></tag>
<tag></tag>
<tag></tag>
html;
}
if(有条件)
{
$foo=像这样吗
if (conditional)
{
$foo = <<<html
<tag></tag>
<tag></tag>
<tag></tag>
<tag></tag>
<tag></tag>
html;
}
if(有条件)
{
$foo=是的,你可以在if
语句中使用herdocs。是的,你可以在if
语句中使用herdocs。只是想说明一下在行的最开头有html;
。一个常见的错误是试图让它与代码的其余部分保持一致。@MitMaro很好的一点。我编辑了我的帖子,就像我编辑的一样你发表了你的评论。这可能是heredocs最被忽视和最令人沮丧的方面。我只是想说明一下,在这行的开头有html;
。一个常见的错误是试图让它与代码的其余部分保持一致。@MitMaro很好。我在你发表评论的时候编辑了我的文章。这可能是most忽视了遗传基因的一些令人沮丧的方面。尝试它比问问题更容易吗?@Ben Shelock:我真的不明白为什么人们如此不愿意尝试。如果尝试后它不起作用,那么你就会问问题。尝试它比问问题更容易吗?@B我真的不明白为什么人们这么不愿意去尝试。如果你尝试后它不起作用,那么你就会问这个问题。