CakeFest 2024: The Official CakePHP Conference

ftp_pwd

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

ftp_pwdカレントのディレクトリ名を返す

説明

ftp_pwd(FTP\Connection $ftp): string|false

パラメータ

ftp

FTP\Connection クラスのインスタンス

戻り値

カレントのディレクトリ名、またはエラー時には false を返します。

変更履歴

バージョン 説明
8.1.0 引数 ftp は、FTP\Connection のインスタンスを期待するようになりました。 これより前のバージョンでは、リソース を期待していました。

例1 ftp_pwd() の例

<?php

// 接続を確立する
$ftp = ftp_connect($ftp_server);

// ユーザー名とパスワードでログインする
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);

// public_html ディレクトリに移動する
ftp_chdir($ftp, 'public_html');

// カレントのディレクトリ名を表示する
echo ftp_pwd($ftp); // /public_html

// 接続を閉じる
ftp_close($ftp);
?>

参考

  • ftp_chdir() - FTP サーバー上でディレクトリを移動する
  • ftp_cdup() - 親ディレクトリに移動する

add a note

User Contributed Notes 1 note

up
5
mike dot hall at opencube dot co dot uk
22 years ago
This function doesn't always go to the remote server for the PWD. Once called the PWD is cached, and until PHP has a reason to believe the directory has changed any call to ftp_pwd() will return from the cache, even if the remote server has gone away.
To Top