PHP dirname() Function
In this chapter you will learn:
- Definition for PHP dirname() Function
- Syntax for PHP dirname() Function
- Parameter for PHP dirname() Function
- Return for PHP dirname() Function
- Example - Get the directory name from a path
Definition
The dirname() function returns the directory name from a path.
Syntax
PHP dirname() Function has the following syntax.
dirname(path)
Parameter
Parameter | Is Required | Description |
---|---|---|
path | Required. | Path to check |
Return
PHP dirname() Function returns the directory name from a path.
Example
<?php
echo dirname("c:/test/home.php") . "\n";
echo dirname("/test/home.php");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP disk_free_space() Function
- Syntax for PHP disk_free_space() Function
- Parameter for PHP disk_free_space() Function
- Return for PHP disk_free_space() Function
- Example - Get the free space for C: drive, in bytes
Home » PHP Tutorial » PHP File Functions