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’);
?>


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

Share This Post

Recent Articles

© 2017 Sumit Bansal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie