fopen( str1, str2 ) fopen( str1, str2, int ) fopen( str1, str2, int, res )
戻り値 | ファイルリソース |
引数1(str1) |
ファイル名、ファイルのURL "./test.txt", "http://php.pi-ppi.com/index.html" など |
引数2(str2) |
オープンモード 'r', 'r+', 'w', 'w+', 'a', 'a+' |
引数3(int) | インクルードパスを含むかのフラグ |
引数4(res) | コールバック |
オープンしたファイルに書き込むには fwrite を使用する。
書込み対象のファイルをクローズするには fclose を使用する。
<?php //ファイルを開く $res_file = fopen( 'output.txt', 'w+' ); //開いたファイルに文字列を書き込む fwrite( $res_file, "1行目\n" ); fwrite( $res_file, "2行目\n" ); fwrite( $res_file, "3行目\n" ); //ファイルを閉じる fclose( $res_file ); ?>
スポンサーリンク
このサイトはリンクフリーです。リンクを貼る際に連絡は不要です。
© since 2005 PHP Webリファレンス all rights reserved.