PHP fwrite()関数
❮PHPファイルシステムリファレンス例
開いているファイルに書き込みます。
<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>
上記のコードの出力は次のようになります。
21
定義と使用法
fwrite()は開いているファイルに書き込みます。
関数は、ファイルの終わり(EOF)または指定された長さに達すると、どちらか早い方で停止します。
構文
fwrite(file, string, length)
パラメータ値
Parameter | Description |
---|---|
file | Required. Specifies the open file to write to |
string | Required. Specifies the string to write to the open file |
length | Optional. Specifies the maximum number of bytes to write |
技術的な詳細
戻り値: | 書き込まれたバイト数、失敗した場合はFALSE |
---|---|
PHPバージョン: | 4.0以降 |
バイナリセーフ: | はい |
❮PHPファイルシステムリファレンス