Question

I'm currently using PHP's mail() function to email the HTML Body of another PHP file using concatenation.

This is currently working fine, however, I would prefer the script to simply get the parsed HTML Body rather than using the concatenation method.

I've read a few incomplete forum posts regarding using fopen() and fread() but had no luck myself. Any output I have got to work has not parsed the PHP within the file.

Is there a function available that can do this?

Was it helpful?

Solution

You can do:

ob_start();
require 'some_script.php';
$html = ob_get_clean();

and then you have the output of the script.

If you need to call a URL, you can do this with cURL or alternatively you can use fopen()/fread() with a URL if that option is enabled in your PHP setup. I think the option is called allow_url_fopen or something similar.

$handle = fopen("http://www.example.com/", "r");
$output = fread($bundle, 20000);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top