What is causing the error "undefined function ftp_connect()" in the PHP script?

The error "undefined function ftp_connect()" occurs because the FTP extension for PHP is not enabled. To solve this issue, you need to enable the FTP extension in your PHP configuration file (php.ini) by uncommenting or adding the line "extension=ftp" and then restart your web server.

<?php
// Enable the FTP extension
extension=ftp
?>