3 php templates output-buffering file-get-contents
这两种获取文件内容的方式有什么区别?哪一种更好,更有效?我认为他们都获得了相同的结果,但我真的不知道哪种方法更好。
例如。
此代码使用输出缓冲来获取文件的内容:
ob_start();
include('foo/bar.tpl');
$output .= ob_get_contents();
ob_end_clean();
Run Code Online (Sandbox Code Playgroud)
此代码使用 file_get_contents 并获得相同的结果。
$output = file_get_contents('foo/bar.tpl');
Run Code Online (Sandbox Code Playgroud)