Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in

Posted on

Delete a file in php in Php

Delete a file in php - Php:


 * function to delete a file
 * @param string $file_name  File name to delete
 * @return $result
function deleteFile($file_name) {
  $result = false;
  // check if file exists
  if (file_exists($file_name)) {
    // delete the file
    $result = unlink($file_name);
  // return the result
  return $result;

$result = deleteFile('test.txt');

echo $result; //true or false
Enter fullscreen mode Exit fullscreen mode

Top comments (0)