PHP rmdir() Function
In this chapter you will learn:
- Definition for PHP rmdir() Function
- Syntax for PHP rmdir() Function
- Parameter for PHP rmdir() Function
- Return for PHP rmdir() Function
- Example - Delete an empty folder
Definition
The rmdir() function removes an empty directory.
Syntax
rmdir(dir,context)
Parameter
Parameter | Is required | Description |
---|---|---|
dir | Required. | Directory to be removed |
context | Optional. | Context of the file handle. |
Return
This function returns TRUE on success, or FALSE on failure.
Example
PHP rmdir() takes a directory name and deletes the specified directory. The directory must be empty; otherwise, the call will fail.
<?php//j a v a 2 s. c om
$path = "images";
if(!rmdir($path)){
echo ("Could not remove $path");
}
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP scandir() Function
- Syntax for PHP scandir() Function
- Parameter for PHP scandir() Function
- Return for PHP scandir() Function
- Example - returns an array of all files and directories
Home » PHP Tutorial » PHP File Functions