over 9 years ago
Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to unlink a directory by using PHP ?
The unlink() function is used to deleted a file.unlink() function returns TRUE on success and FALSE on failure.
syntax of unlink() function
There are two main parameter in above example:
1-filename:-This is required parameter
2-context:- This is optional parameter
you can see below example:
- <?php
- //here define a dir file
- $dir_file = "file.txt";
- //here call unlink() and check
- if (!unlink($dir_file))
- {
- echo ("Fail ! Error deleting $dir_file");
- }
- else
- {
- echo ("Success ! Deleted $dir_file");
- }
- ?>
<?php //here define a dir file $dir_file = "file.txt"; //here call unlink() and check if (!unlink($dir_file)) { echo ("Fail ! Error deleting $dir_file"); } else { echo ("Success ! Deleted $dir_file"); } ?>
The output of the code above will be:
0 Comment(s)