I\'m messing around with templating and I\'ve run into a situation where I need to echo to the browser a template that contains html & php. How do I evaluate the PHP and
Use output buffering instead. eval() is notoriously slow.
main.php:
10): ?>
Greater than 10!
Less than 10!
Your file:
$title = 'Lorem Ipsum';
$id = 11;
ob_start();
require_once('main.php');
$contents = ob_get_contents();
ob_end_clean();
echo $contents;
The output of this will be:
Lorem Ipsum
Greater than 10!