0

Is there anyway to get make a variable equal the content of the body?

Example:

<?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 } ?>

So that I can use it send a e-mail.

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

4 Answers 4

4

Yes - use the output buffering functions:

ob_start();

// Echo your output here or

?>

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

<?php

$output = ob_get_clean();
Sign up to request clarification or add additional context in comments.

Comments

3

You can use heredoc in PHP

<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

Comments

1

try this

<? 

$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>"

?>

Comments

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>';

 ?>

1 Comment

Dangerous - what happens if a ' appears in the output?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.