PHP Output buffering on the command line
问题 I have a PHP script that I want to run on the command line. This script, among other things, needs to load a PHP file that contains both PHP and HTML content and get the rendered output from that file. This code does exactly what I need, but not when run from the command line: <?php // ... if(file_exists($content_file)) { ob_start(); include($content_file); $content = ob_get_contents(); ob_end_clean(); } ?> When run in the browser, my script gets the rendered output of the PHP file via