0

I have built an html string that is used for 2 purposes:

  1. output to browser
  2. Send as a fully formatted email.

This script work perfect for sending email but not for outputting the the browser. Here is the basic build:

  function makeformatedmessage(){ 
  $message = '';
  $message .= '
  <html>
  <head>
  <title>Some title</title>
  </head>
  <body>';

  $message .='complex html body';
  $message .='complex html body 2';
  $message .='</body>
  </html>';

  return $message;

 }

When I send this as an email everything is sent but when i output to the browser only $message .='complex html body 2' part of the message is missing. Is there a better way to store html and output to the browser.

EDITED I descovered through closer debugging that there was a another file with the same function that was been called in the browser. After I removed it it worked as it should.

3
  • 1
    How are you displaying it in the browser? Commented Jan 5, 2013 at 2:20
  • 2
    You might have to post that "complex html body". I can't test right now but I'm almost certain this specific example (echo makeformatedmessage();) would work just fine. Commented Jan 5, 2013 at 2:20
  • I output the browser like this: echo makeformatedmessage(); Commented Jan 5, 2013 at 2:26

1 Answer 1

2

When I run:

 <?php

 function makeformatedmessage(){ 
 $message = '';
 $message .= '
 <html>
 <head>
 <title>Some title</title>
 </head>
 <body>';

 $message .='complex html body';
 $message .='complex html body 2';
 $message .='</body>
    </html>';

 return $message;

}

echo makeformatedmessage();

?>

The source output to my browser (as expected) is:

<html>
<head>
<title>Some title</title>
</head>
<body>complex html bodycomplex html body 2</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

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.