0

反正有没有让变量等于正文的内容?

例子:

<?php 

//PHP

$body = { ?>

<!-- HTML -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>


<?php } ?>

这样我就可以使用它发送电子邮件。

$success = mail($EmailTo, $Subject, $Body, 'From: <$EmailFrom>');
4

4 回答 4

4

是 - 使用输出缓冲功能:

ob_start();

// Echo your output here or

?>

<div>Just output your HTML like this</div>

<?php

$output = ob_get_clean();
于 2013-07-16T05:02:37.220 回答
3

您可以在 PHP中使用heredoc

<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
于 2013-07-16T05:02:55.770 回答
1

尝试这个

<? 

$body = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
$body .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
$body .= "<head>"
$body .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
$body .= "<title>Untitled Document</title>"
$body .= "</head>"
$body .= "<body>"
$body .= "</body>"
$body .= "</html>"

?>
于 2013-07-16T05:08:59.783 回答
0
check this way

<?php 

//PHP

$body = '

<!-- HTML -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>';

 ?>
于 2013-07-16T05:02:55.360 回答