I am trying to generate an email with some HTML that is created via another PHP file.
Email generating file is run by a cron running every hour. Another file exists that
Check out the built-in functions ob_start and ob_get_clean.
You can then do something like:
ob_start();
include( "file.php");
$var = ob_get_clean();
If I understood what you said, you can use output buffering,
so that you can get the output of htmlGenerator.php
For example:
ob_start();
// as an example
echo "Hello World";
// or in our case
include "htmlGenerator.php";
$result = ob_get_contents();
ob_end_clean();
You can also create a simple function like this:
function include_output($filename)
{
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
$mycontent = include_output("htmlGenerator.php");
Read the php documentation for further details.