downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SplFileObject::getChildren> <SplFileObject::ftruncate
[edit] Last updated: Fri, 25 May 2012

view this page in

SplFileObject::fwrite

(PHP 5 >= 5.1.0)

SplFileObject::fwriteファイルに書き込む

説明

public int SplFileObject::fwrite ( string $str [, int $length ] )

Writes the contents of string to the file

パラメータ

str

ファイルに書き込まれる文字列。

length

length 引数が渡される場合、length バイト分だけ書き込まれた後もしくは string の終端に達するのどちらか早い方の後で書き込みが停止します。

返り値

書き込まれるバイト数、もしくはエラーの場合 NULL を返します。

例1 SplFileObject::fwrite() の例

<?php
$file 
= new SplFileObject("fwrite.txt""w");
$written $file->fwrite("12345");
echo 
"$written バイトをファイルに書き込みました";
?>

上の例の出力は、 たとえば以下のようになります。

Wrote 5 bytes to file

参考

  • fwrite() - バイナリセーフなファイル書き込み処理



add a note add a note User Contributed Notes SplFileObject::fwrite
There are no user contributed notes for this page.

 
show source | credits | sitemap | contact | advertising | mirror sites