What is the function in PHP used to check if an FTP server is active and what parameters does it take?

To check if an FTP server is active in PHP, you can use the ftp_connect() function. This function creates an FTP connection to a specified server. To check if the server is active, you can attempt to connect to it and check if the connection was successful. The ftp_connect() function takes the FTP server address as a parameter.

$ftp_server = 'ftp.example.com';
$ftp_connection = ftp_connect($ftp_server);

if($ftp_connection){
    echo 'FTP server is active';
    ftp_close($ftp_connection);
} else {
    echo 'FTP server is not active';
}