• PHP Video Tutorials

PHP - Function dirname()



The dirname() function can return the directory name from a path.

Syntax

string dirname ( string path )

Example

<?php
   echo dirname("C:/PhpProject/index.php") . "\n";
   echo dirname("/PhpProject/index.php");
?>

Output

C:/PhpProject
/PhpProject
php_function_reference.htm
Advertisements