What are the best practices for managing file permissions and access rights when using PHP to create folders for FTP access?

When creating folders for FTP access using PHP, it is important to set appropriate file permissions and access rights to ensure security and proper functionality. This can be done by using the `chmod()` function in PHP to set the desired permissions for the newly created folders. It is recommended to set permissions to allow only the necessary level of access for the FTP user, while restricting access for others.

// Create a new folder
$folder = 'new_folder';
mkdir($folder);

// Set permissions for the folder
chmod($folder, 0755);