Home > Article > Backend Development > How to delete server files in php
You can use the "ftp_delete" function to delete server files in PHP. The syntax is "ftp_delete(ftp_connection,file)". The parameter "ftp_connection" indicates the FTP connection to be used, and the parameter "file" indicates the file to be deleted. The path to the file.
Recommended: "PHP Video Tutorial"
PHP ftp_delete() function
Definition and usage
ftp_delete() function deletes a file on the FTP server.
If successful, this function returns TRUE. On failure, returns FALSE and a warning.
Syntax
ftp_delete(ftp_connection,file)
Parameters
ftp_connection Required. Specifies the FTP connection to use.
file Required. Specifies the path of the file to be deleted.
Example
<?php $conn = ftp_connect("ftp.testftp.com") or die("Could not connect"); ftp_login($conn,"admin","ert456"); echo ftp_delete($conn,"test.txt"); ftp_close($conn); ?>
The above code will output:
1
The above is the detailed content of How to delete server files in php. For more information, please follow other related articles on the PHP Chinese website!