fwrite寫入字串
<?php
$file = fopen(“test。txt”,“w”);
echo fwrite($file,“Hello World。 Testing!”);
fclose($file);
?>
上面的程式碼將輸出:
21
file_put_contants寫入字串
<?php
file_put_contants(“test。txt”,“Hello World。 Testing!”);
?>
一句話,file_put_contants() 封裝了封裝了檔案開啟,關閉的過程。