Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP include without echo of data in mail function

I am using a PHP include function to add content to an email sent out. Problem is I don't want to echo the file too, I only want to include it as the $message.

Whats the equivalent of include that returns the string without the echo.

$message = include('email/head.php');
like image 200
RIK Avatar asked May 20 '26 17:05

RIK


1 Answers

Use output buffering.

ob_start();
include('email/head.php');
$message = ob_get_contents();
ob_end_clean();

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!