How to Get generated html content of php script on same server


How to retrieve this HTML source code dynamically via PHP.  with passing query string at the end of the URL to get the result in HTML source code.

And Generating file to store HTML code.


Let's go through the example 

URL:   example.com/report.php?date=2018-01-06


Here the complete code of generating HTML Source code dynamically in PHP



$url = 'report.php';
ob_start();
$original_get = $_GET;
$_GET = ["date" => "2018-01-06", "you" => "need", "in" => "report.php"];

include($url);
$html = ob_get_contents();
ob_end_clean();

echo "=====". $html;
$fName = rand(10000,99999).".txt";
$myfile = fopen("report/".$fName."", "w");
fwrite($myfile, $html);
fclose($myfile);

No comments:

Post a Comment