php can delete files. The method of deleting files: 1. Create a PHP sample file; 2. Find the file to be deleted; 3. Delete the file through the "unlink(filename,context)" syntax. .
#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
Can php delete files?
php can delete files.
php can use the unlink function to delete files
The specific usage is as follows
unlink($filename);
unlink() Function introduction:
unlink() Function deletes files.
If successful, this function returns TRUE. On failure, returns FALSE.
Syntax
unlink(filename,context)
Parameters
filename required. Specifies the files to be deleted.
context Optional. Specifies the environment for a file handle. context is a set of options that can modify the behavior of the stream.
Example
<?php $file = "test.txt"; if (!unlink($file)) { echo ("Error deleting $file"); } else { echo ("Deleted $file"); } ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Can php delete files?. For more information, please follow other related articles on the PHP Chinese website!