douzhan1994 2016-08-23 23:30
浏览 25

如何使用POST变量将大量HTML代码设置为PHP中的变量?

$content = '<div id="contact" style="display:''; border-radius: 5px; padding: 20px;" class="center"><br><!--Spacing--><br><!--Spacing--></div>
<div id="contact" style="display:''; border-radius: 5px; background-color: #EBEBEB; padding: 20px;" class="center">
<form>
<center><h4><b>' . $_POST['email1'] . " " . $_POST['email2'] . '</b></h4></center>
<br><!--Spacing-->
<center>' . $_POST['email4'] . '<center>
<br><!--Spacing-->
<center>' . $_POST['email3'] . '<center>
<br><!--Spacing-->
<center>' . $_POST['email5'] . '<center>
<br><!--Spacing-->
<center><img src="rushforms/profile_images/' . $_POST['file_number'] . '.png"/></center>
<center><img src="rushforms/profile_images/' . $_POST['file_number'] . '.jpg"/></center>
<center><img src="rushforms/profile_images/' . $_POST['file_number'] . '.gif"/></center>
</form>
</div>';

How can I set all of this to $content?

I was under the impression that ' ' could be used to set html code to a variable in php.

  • 写回答

1条回答 默认 最新

  • drecy22400 2016-08-23 23:57
    关注

    It will work but when you have such content it can be easier to use heredoc or nowdoc syntax .

    It will avoid all that concatenations.

    评论

报告相同问题?