In that case you'll have to use the output buffering method ob_start(); The include() function parses and executes any valid PHP code within the file and produces output (if any). Output buffering captures the display output and stores it until you clean the buffer or the script terminates.
ob_start(); include ("header.php"); include ("body.php"); include ("footer.php"); $out = ob_get_contents(); ob_end_clean(); echo $out; Note: instead of ob_end_clean() you can also do ob_end_flush() to send the output to the display and destroy the buffer simultaneously. -Kevin ----- Original Message ----- From: "J. Alden Gillespy" <[EMAIL PROTECTED]> To: "PHP-general" <[EMAIL PROTECTED]> Sent: Friday, July 12, 2002 12:42 PM Subject: Re: [PHP] PHP codes and variables > Which method makes it possible to process any variables in the included > file? See, I have variables in the included file that are defined in the > page that's calling it. > > J. Alden Gillespy (DJ Rage) > Broadcasting on Test Pattern Radio > Shock Rock! Every Sunday 5-8pm edt (21-0 gmt) > http://www.thetestpattern.com > > ----- Original Message ----- > From: "Kevin Stone" <[EMAIL PROTECTED]> > To: "PHP-general" <[EMAIL PROTECTED]> > Sent: Friday, July 12, 2002 2:35 PM > Subject: Re: [PHP] PHP codes and variables > > > > Or use implode instead of join makes skips the step of extracting the > > index.. > > $file = implode ('', file ("afile.html")); > > > > If you'll be sending more output than just one file then another favorite > > method is this.. > > ob_start(); > > readfile("file1.txt"); > > readfile("file2.html"); > > $output = ob_get_contents(); > > ob_end_clean(); > > > > -Kevin > > > > ----- Original Message ----- > > From: "Miguel Cruz" <[EMAIL PROTECTED]> > > To: "J. Alden Gillespy" <[EMAIL PROTECTED]> > > Cc: "Groups - PHP-General" <[EMAIL PROTECTED]> > > Sent: Friday, July 12, 2002 12:17 PM > > Subject: Re: [PHP] PHP codes and variables > > > > > > > On Fri, 12 Jul 2002, J. Alden Gillespy wrote: > > > > Anyone know how to do have a variable equal the contents of a file? I > > tried > > > > the include function, but it just prints the file out on the screen > > rather > > > > than including the contents in the variable itself. I need help with > > this > > > > ASAP. Thanks. > > > > > > $variable = join('', file('path/to/file')); > > > > > > miguel > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php