What are the implications of using different paths (document root, server root, ftp program path) in PHP scripts for functions like ftp_mkdir()?

When using functions like ftp_mkdir() in PHP scripts, it is important to ensure that the paths being used are consistent across different contexts such as the document root, server root, and FTP program path. Failure to do so may result in errors or unexpected behavior. To solve this issue, it is recommended to define a base path variable that can be used consistently throughout the script.

// Define a base path variable
$basePath = '/path/to/ftp/directory/';

// Use the base path variable consistently in the script
$ftpConnection = ftp_connect('ftp.example.com');
ftp_login($ftpConnection, 'username', 'password');
ftp_mkdir($ftpConnection, $basePath . 'new_directory');
ftp_close($ftpConnection);