Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to removes a directory in php ?
If you want removes a directory then you should use The rmdir() function that is removes an empty directory.
The rmdir() function returns "TRUE" on success and "FALSE" on failure.
syntax of rmdir() function
rmdir(dir,context);
There are two main parameter in above example:
1-Dir:-This is required parameter
2-Context:- This is optional parameter
you can see below example
<?php
//here define a dir variable
$Dir_path = "img";
//here call rmdir()
if(!rmdir($Dir_path))
{
echo ("Could not remove $Dir_path");
}
?>
The output of the code above will be:
Could not remove img
0 Comment(s)