CakeFest 2024: The Official CakePHP Conference

posix_getcwd

(PHP 4, PHP 5, PHP 7, PHP 8)

posix_getcwd現在のディレクトリのパス名

説明

posix_getcwd(): string|false

スクリプトの現在の実行ディレクトリのパスを、絶対パスで取得します。 エラー時には errno を設定します。この値は posix_get_last_error() で取得することができます。

パラメータ

この関数にはパラメータはありません。

戻り値

絶対パスを表す文字列を返します。 エラー時には false を返し、errno を設定します。この値は posix_get_last_error() で取得することができます。

例1 posix_getcwd() の例

この例は、このスクリプトの現在の作業ディレクトリの絶対パスを返します。

<?php
echo '現在の作業ディレクトリは '.posix_getcwd();
?>

注意

注意:

以下のような場合は、この関数は失敗します。

  • 読み込みあるいは検索の権限が取得できない
  • パスが存在しない

add a note

User Contributed Notes 1 note

up
0
phpmanual-getcwd at devin dot com
23 years ago
From the GNU getcwd(3) manpage, paraphrased: returns the absolute pathname of the current working directory. Fails when the current directory is not eradable. Complies with POSIX.1 spec.
To Top