本文介紹了將php輸出保存在文件中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我有:
echo"
";echo"
";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 打印的內(nèi)容保存到一個文件中(不要在頁面中打印任何內(nèi)容).
我知道我需要做這樣的事情:
$f = fopen("file.txt", "w");fwrite($f, "要寫的文本");fclose($f);
但是我不知道怎么把里面的內(nèi)容放在里面.
感謝一百萬
解決方案
使用 print_r
中的 true
參數(shù)試試這個:
$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);
I have:
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>";
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 a million
解決方案
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);
這篇關(guān)于將php輸出保存在文件中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!