Is it possible to assign the contents of a simple html page to a variable?
$mail = (require("mail.html"));
The purpose is to include text from a web page in an email instead of text from a database.
Is it possible to assign the contents of a simple html page to a variable?
$mail = (require("mail.html"));
The purpose is to include text from a web page in an email instead of text from a database.
You can use file_get_contents
to read the contents of a web page:
$mail = file_get_contents('mail.html');
Use file_get_contents()
. You can use this function to get content into a variable
$mail = file_get_contents("mail.html");
http://php.net/manual/en/function.file-get-contents.php
or use readfile (not recommneded though)
ob_start();
readfile("text.txt");
$data = ob_get_clean();
Try this
ob_start();
require_once "mail.html";
$mail = ob_get_contents();
ob_end_clean();
your requirment needed file_get_contents().try below code:
$mail = file_get_contents('mail.html');