Jump to content

include


westman
 Share

Recommended Posts

hi all, i need to include a php file that has only text in it into a $. i have this so fear...

$email_message = '<html><body bgcolor="#FFFFFF">' . $name_of_the_sender . ' invites you to join them on the site.<br /><br />Thank you.include "../email.php"</body></html>'; 

my include "../email.php" is not working how do i get it working in this way?

Link to comment
Share on other sites

Guest So Called

Seriously?

$variable = file_get_contents('file_with_text_stuff.txt');

Put it in the same directory as your PHP script, or add path info. Then in your script you can just .= $variable, or use $variable in a double quoted character string. Or how about ...Thank you.' . $variable . '</body... (or put the included text wherever you want).

Link to comment
Share on other sites

Here's basically what I think So Called is referring to and what I'm assuming you're trying to do:

<?php$name_of_the_sender = 'John Doe'; // added this for obvious reasons  $message = '<!doctype html><html><body bgcolor="#FFFFFF">'.$name_of_the_sender  . ' invites you to join them on the site.<br /><br />Thank you';$message .= file_get_contents('sayhello.html'); // Don't think this will work with a php file because when echoing $message below, it outputs/includes everything even the php tags etc. If you look at the source file, you'll see php tags etc. sayhello.html only has <h4>hello world</h4> in it in this example.$message .= '</body></html>';  echo $message; //  All the above even what's in sayhello.html is stored in $message.?>

As for how you're going to do this with the email.php file though(using the above method, file_get_contents()), I'm not sure because of what's mentioned in the above comment.

Link to comment
Share on other sites

file_get_contents() wont execute the codes which it have. where include will execute it. when you use

$message = file_get_contents('mail.php');
it is just pulling the source code of mail.php rather than executing it. in other words...
$message = file_get_contents('core_mail.html');
this wont work.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...