PHP - Fonction dirname ()

La fonction dirname () peut renvoyer le nom du répertoire à partir d'un chemin.

Syntaxe

string dirname ( string path )

Exemple

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

Production

C:/PhpProject
/PhpProject