LoginSignup
1
0

More than 5 years have passed since last update.

file_put_contents関数でデータをファイルに出力

Last updated at Posted at 2018-03-26

file_put_content("作成するファイルの名前","出力したいデータ","フラグ”)
を使って、データをファイルに出力することができます。
フラグは省略可能です。

$a = $_POST('data');
file_put_contents("new_file",$a);//フラグなし

また、フラグを使って、書き方の種類などを指定することができます。
私は、FILE_APPEND_FLAGという、
「前回書いたものはそのまま残して、同じファイルの続きに記述を追加しろ」
って意味のフラグをよく使います。

$a = $_POST('data');
file_put_contents("new_file",$a,FILE_APPEND_FLAG);

フラグの種類は他にもあるので、詳しく知りたい方は以下のサイトを参照してください。
http://php.net/manual/ja/function.file-put-contents.php

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0