保存PHP输出文件 [英] Saving php output in a file
本文介绍了保存PHP输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有:
echo"<br>";echo"<br><pre>";print_r($array2);echo"</pre>";
echo"<br>";echo"<br><pre>";print_r($array3);echo"</pre>";
echo"<br>";echo"<br><pre>";print_r($array4);echo"</pre>";
我需要什么所有这些print_r的打印保存到一个文件中(不pronting在页面的任何东西)。
I need to save what all of these print_r print into a file (without pronting anything in the page).
我知道我需要做这样的事情:
I know I need to do something like that:
$f = fopen("file.txt", "w");
fwrite($f, "TEXT TO WRITE");
fclose($f);
但我不知道如何在它之前提出的内容。
But I don't know how to put the contents before in it.
Thansk百万
推荐答案
使用试试这个出了真正
参数在的print_r
:
Try this out using the true
param in the print_r
:
$f = fopen("file.txt", "w");
fwrite($f, print_r($array2, true));
fwrite($f, print_r($array3, true));
fwrite($f, print_r($array4, true));
fclose($f);
这篇关于保存PHP输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文