How to delete the file using php

We can delete the file using php with the help of unlink function.


Define this function like this:

unlink ( string $filename [, resource $context ] )

Parameter:

File name:

Path to the file.

Context:

Context support was added with PHP 5.0.0

Example:

<?php
$fh = fopen(‘file.html’, ‘a’);
fwrite($fh, ‘<h1>Hello world!</h1>’);
fclose($fh);

unlink(‘file.html’);
?>

Bansal Sumit

To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.