Output buffer versus file_get_contents in PHP
What are the differences between these two ways to get the file content? Which one is better and more effective? I think they will both get the same results, but I really don't know which method is better.
This code uses output buffering to get the contents of the file:
ob_start(); include('foo/bar.tpl'); $output .= ob_get_contents(); ob_end_clean();
This code uses file_get_contents and gets the same results.
$output = file_get_contents('foo/bar.tpl');
source to share