Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get render HTML from local PHP file [duplicate]

Tags:

php

I have PHP file for make table with data row from database . I want send this page to email . but when I get content contains HTML and PHP code . but I want send only result of page in HTML.

i use this code

    $str =  file_get_contents( 'template.php' );
    $mail = "[email protected]";
    mail($mail,$str);

and this

$str = readfile("'template.php'");

but result contains php code in email . how i can get only html result?

like image 840
bnnoor Avatar asked Mar 17 '14 06:03

bnnoor


1 Answers

function getRenderedHTML($path)
{
    ob_start();
    include($path);
    $var=ob_get_contents(); 
    ob_end_clean();
    return $var;
}

This function will do what you want.

like image 142
schnawel007 Avatar answered Oct 11 '22 10:10

schnawel007