Example 1 — Show the Starting Directory
Log in and print the folder the server puts you in.
<?php
$ftp = ftp_connect('ftp.example.com');
ftp_login($ftp, 'demo', 'secret');
echo "Current folder: ", ftp_pwd($ftp), PHP_EOL;
ftp_close($ftp); How It Works
- ftp_connect() and ftp_login() open the session.
- ftp_pwd() asks the server for the current working directory.
- The server answers with a path, here the root folder.
- echo prints that path and ftp_close() ends the session.

