搜尋

首頁  >  問答  >  主體

讀取新建立的暫存檔案內容報錯的問題

<?php
//建立一個暫存檔案
$lsfile = tmpfile();

//向裡面寫入資料
$lsshuju = fwrite($lsfile, '111這裡是寫入臨時檔案的資料');

//輸出寫入情況
echo '向臨時檔案中寫入了' . $lsshuju . '個字元<br>' ;

//輸出暫存檔案的內容
$shuchu = file_get_contents($lsfile);
echo $shuchu;

//關閉暫存檔案
fclose($ lsfile);
?>


讀取內容報錯,請問如何讀取內容正確?

LIWENLIWEN2804 天前1402

全部回覆(1)我來回復

  • ringa_lee

    ringa_lee2017-06-14 21:15:05

    報什麼錯的

    回覆
    0
  • LIWEN

    向臨時文件中寫入了39個字符 Warning: file_get_contents() expects parameter 1 to be a valid path, resource given in /home/phpcn6peh2pwcun/wwwroot/compile.php(30) : eval()'d code on line 12

    LIWEN · 2017-06-15 09:02:41
    ringa_lee

    報錯的是$lsfile這個變數不是有效的路徑

    ringa_lee · 2017-06-15 09:14:49
  • 取消回覆