LoginSignup
2
2

More than 5 years have passed since last update.

【PHP】現在・一つ上・ホームディレクトリの位置を取得する

Posted at

絶対PATHで取得。

// 現在のディレクトリを取得
echo getcwd() . "\n";
// 現在の一つ上のディレクトリを取得
echo realpath("../") . "\n";
// ホームディレクトリを取得
echo posix_getpwuid(posix_geteuid())['dir'] . "\n";

参考リンク

カレントのワーキングディレクトリを取得する
絶対パス名を返す
PHP でホームディレクトリを取得

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