Deleting files : unlink « File Directory « PHP






Deleting files

 
<?php   
  function delete( $file )
  {
    if( unlink( $file ) )
    { 
      echo( "$file<br>has been deleted<hr>" ); 
    }
    else
    { 
      echo( "Unable to delete $file<hr>" ); 
    }
  }
?>

<html>

 <head>
  <title>Deleting files</title>
 <head>

 <body>

 <?php 
  # for Linux use...
  #$file_A = "/errlog_bak";
  #$file_B = "/errlog_not";

  # for Windows use...
  $file_A = "C:\\errlog.bak";
  $file_B = "C:\\errlog.not";

  delete($file_A);
  @delete($file_B);
  ?>

 </body>

</html>
  
  








Related examples in the same category

1.Deleting Files with unlink( )
2.Delete a file with the unlink() function.
3.Using file_exists, touch, and unlink together
4.Using the unlink() Function
5.You can remove an existing file with the unlink() function.
6.Deleting a file
7.Moving a file across filesystems