Reputation:
I am developing php-based websites. When I try to load a file from the same directory using file_get_contents, the server did return some string, but php code of that file are also returned. I want the file after compiled by php, not the native code. How can I fix this problem?
Upvotes: 0
Views: 129
Reputation: 624
When wanting use the contents of a PHP file for example to create a pdf, and you want the parsed output, not the code, one can trap the output buffer of the include operation.
ob_start();
include 'something.php';
$html = ob_get_clean();
ob_end_clean();
$this->mpdf->WriteHTML($html);
Upvotes: 0