fputs
fwrite 的別名
fputs()
函數寫入文件(可安全用於二進製文件)。
fputs()
函數是fwrite()
函數的別名。
<?php $file = fopen ( "test.txt" , "w" ) ; echo fputs ( $file , "Hello World. Testing!" ) ; fclose ( $file ) ; ?>
輸出:
21
fputs ( file , string , length )
參數 | 描述 |
---|---|
file | 必需。規定要寫入的打開文件。 |
string | 必需。規定要寫入文件的字符串。 |
length | 可選。規定要寫入的最大字節數。 |
fwrite()
把string的內容寫入文件指針file處。 如果指定了length ,當寫入了length個字節或者寫完了string以後,寫入就會停止,視乎先碰到哪種情況。
fwrite()
返回寫入的字符數,出現錯誤時則返回false。