<?PHP // 作成するファイル名の指定 $file_name = 'file.txt'; // ファイルの存在確認 if( !file_exists($file_name) ){ // ファイル作成 touch( $file_name ); }else{ // すでにファイルが存在する為エラーとする echo('Warning - ファイルが存在しています。 file name:['.$file_name.']'); exit(); } // ファイルのパーティションの変更 chmod( $file_name, 0666 ); echo('Info - ファイル作成完了。 file name:['.$file_name.']'); ?>
| ■ | file_exists | bool file_exists( string filename ) | ファイルまたはディレクトリが存在するかどうか調べる |
| ■ | touch | bool touch( string filename [, int time [, int atime]] ) | ファイルの最終アクセス時刻および最終更新日をセットする |
| ■ | echo | void echo( string arg1 [, string ...] ) | 1つ以上の文字列を出力する |
| ■ | exit | void exit( [string status] ) | メッセージを出力し、カレントのスクリプトを終了する |
| ■ | chmod | int chmod( string filename, int mode ) | ファイルのモードを変更する |