PHP

Topic: Files

How To Remove a File?

If you want to remove an existing file, you can use the unlink() function. Here is a PHP script example on how to use unlink():<?phpif (file_exists("/temp/todo.txt")) {  unlink("/temp/todo.txt");  print("File removed.\n");} else {  print("File does not exist.\n");}?>This script will print:File removed.If you run this script again, it will print:File does not exist.

Browse random answers: