how to redirect STDOUT to a file in PHP?

前端 未结 7 1082
不思量自难忘°
不思量自难忘° 2020-11-27 11:56

The code below almost works, but it\'s not what I really meant:

ob_start();
echo \'xxx\';
$contents = ob_get_contents();
ob_end_clean();
file_put_contents($f         


        
7条回答
  •  悲&欢浪女
    2020-11-27 12:08

    No, output buffering is as good as it gets. Though it's slightly nicer to just do

    ob_start();
    echo 'xxx';
    $contents = ob_get_flush();
    file_put_contents($file,$contents);
    

提交回复
热议问题