1
1

More than 1 year has passed since last update.

【PHP】ファイル操作系いろいろ

Last updated at Posted at 2022-03-11

basename() ファイルパスからファイル名を取得する。

参考:http://www.openreference.org/articles/view/496

basename
basename( "/tmp/file/hoge.txt" );          // => "hoge.txt"
basename( "/tmp/file/hoge.txt", ".txt" );  // => "hoge"
basename( "/tmp/file/ );                   // => "file"

rename() ファイルを移動する。

参考:https://www.flatflag.nir87.com/copy-895

dir
 ├─ tmp
 │   └─ hoge.txt =>これをfileに移動したい。
 └─ file
rename
rename('tmp/hoge.txt', 'file/hoge.txt');

unlink() ファイルを削除する。

参考:https://www.sejuku.net/blog/25804

unlink
unlink('tmp/hoge.txt'); // => 削除成功でTRUE、失敗でFALSEを返す。

メモ代わりに使用しているので増えるかもです。

1
1
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
1