PHP dirname() Function, PHP dirname(), dirname php


 

PHP dirname() Function, PHP dirname(), dirname php

The example of PHP dirname() Function. Learn how to get the directory name of a file. It gives the name (full path) of the directory in which the file is present.

The example of PHP dirname() Function. Learn how to get the directory name of a file. It gives the name (full path) of the directory in which the file is present.

In this example we will explain the use of dirname() function in PHP. The dirname() function is used to get the full directory path name of the file. The following code snippet shows the correct use of dirname function.

Syntax of PHP dirmane()Function

String dirname ($path )

It returns the directory name of the specified file.

Code dirmane()Function in PHP

<?php

$dir1=dirname("c:/xampp/htdocs/filehandling/copy1.php");

echo $dir1;

echo"<br>";

$dir2=dirname("c:/xampp/htdocs/aa.php");

echo $dir2;

?>

Output

c:/xampp/htdocs/filehandling
c:/xampp/htdocs

 

Ads