What are the potential pitfalls of using PHP for FTP operations?
One potential pitfall of using PHP for FTP operations is that plain text passwords may be exposed in the code, posing a security risk. To mitigate this, it is recommended to store sensitive information like passwords in a separate configuration file outside of the web root directory. This way, the passwords are not directly accessible to external users.
// config.php
<?php
define('FTP_USERNAME', 'your_username');
define('FTP_PASSWORD', 'your_password');
define('FTP_HOST', 'ftp.example.com');
define('FTP_PORT', 21);
```
```php
// ftp_operations.php
<?php
require_once('config.php');
$ftp_connection = ftp_connect(FTP_HOST, FTP_PORT);
$login = ftp_login($ftp_connection, FTP_USERNAME, FTP_PASSWORD);
// Perform FTP operations here
ftp_close($ftp_connection);