Assigning an include file to a variable

Here is the code I have at the top of my page:

flush();
ob_start();
include(‘preventSpam.php’);
$preventSpam = ob_get_clean();

Here is the code that I have towards the bottom of my page:

$pageIntro .= "<p>$formFirstName, thank you for registering. An email has been sent containing a confirmation link. Click on this link to finalize your registration. You will then be able to login and conduct keyword searches and post your own testimonials.</p>

<h1>Spam Filters</h1>

<p>Sometimes legitimate email mistakingly gets flagged as spam by internet service providers. Take action now to ensure your confirmation email does not get filtered into your junk or bulk mail folder.</p>";

echo $preventSpam;

Here is the error I’m getting when the page is loaded:

Warning: Cannot modify header information - headers already sent by (output started at /home3/recordau/public_html/newVersion/register.php:876) in/home3/recordau/public_html/newVersion/startSession.php on line [B]4

What is the best way to display the contents of an include file since this doesn’t seem to work?

Thanks!

[/B]

Is there a particular reason you need to do all this instead of include’ing the file where you have the echo statement?

I tried that and got an error. You see, I need the contents of that external file to be added to the $pageIntro variable so later the whole thing can be displayed, like this:

$pageIntro .= " contents of the include file ";

What is the best way to do this?

Thanks!

does preventSpam.php actually include PHP code? Or is it just HTML?

It’s just HTML.

[FPHP]file_get_contents[/FPHP] it instead of including it.

Also check to make sure there are no contents outputted before the header() is called.

Thank you, that did the trick brother!