How to Check ftp connection in php

set_time_limit(300);//for setting
$path=’/’.date(‘dmY’).”;
$ftp_server=’************’; // Server ip or hostname
$ftp_server_port=”21″; // port to connect serve
$ftp_user_name=’************’; // username of your server ftp
$ftp_pass=”*********”; // password for you server ftp

// set up a connection to ftp server
$conn_id = ftp_connect($ftp_server, $ftp_server_port);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_pass);

// check connection and login result
if ((!$conn_id) || (!$login_result)) {
echo “FTP connection Failed
“;
} else {
echo “Ftp connection Success
“;
// enabling passive mode
ftp_pasv( $conn_id, true );
// get contents of the current directory
$contents = ftp_nlist($conn_id, $path);
// output $contents
var_dump($contents);
}

// close the FTP connection
ftp_close($conn_id);

// It shows ftp connection is working or not