English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and Examples of PHP dirname() Function

PHP Filesystem Reference Manual

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

Syntax

string dirname ( string path )

Online Example

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

Output Result

C:/PhpProject
/PhpProject

PHP Filesystem Reference Manual