Delete unlink () in PHP,
Please refer to the tutorial on creating a PHP file. We created a file named testfile.txt.
$ MyFile = "testFile.txt"; $ fh = fopen ($ myFile, 'w') or die ("can't open file"); fclose ($ fh ); determine whether the object has been deleted. http://www.manongjc.com/article/1351.html?myfile = "testFile.txt"; unlink ($ myFile );
Example
$ Filename = 'file.txt '; fopen ($ filename, 'a +'); if (! Unlink ($ filename) {echo "failed to delete the file {$ filename}"; // http://www.manongjc.com/article/1351.html?else=echo "the file {$ filename} has been deleted successfully";}?>
Delete all files in the directory
Function delFileUnderDir ($ dirName = "../Smarty/templates/templates_c") {// http://www.manongjc.com/article/1351.htmlif ($ handle = opendir ("$ dirName") {while (false! ==( $ Item = readdir ($ handle) {if ($ item! = "." & $ Item! = ".. ") {If (is_dir (" $ dirName/$ item ") {delFileUnderDir (" $ dirName/$ item ");} else {if (unlink ("$ dirName/$ item") echo "successfully deleted the file: $ dirName/$ item <br/> n ";}}} closedir ($ handle );}}