« posix_get_last_error
posix_getegid »

posix_getcwd

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

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

説明

function posix_getcwd(): string|false

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

パラメータ

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

戻り値

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

例

例1 posix_getcwd() の例

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

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

注意

注意:

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

  • 読み込みあるいは検索の権限が取得できない

  • パスが存在しない

関連キーワード:
getcwd   last   絶対パス   スクリプト   errno   作業   getegid   権限
関連する関数・ページ:
function.getcwd   ds-set.last   function.eio-realpath   function.posix-errno   function.chdir   function.posix-get-last-error