Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

PHP Function dirname()


previous

Syntax

string dirname ( string $path );

Definition and Usage

Given a string containing a path to a file, this function will return the name of the directory.

Paramters

ParameterDescription
pathA file path.

Return Value

Returns the base name of the given path.

Example

Following is the usage of this function:

<?php
$path = "/home/httpd/html/index.php";
$dir = dirname($path);
echo "dirname is $dir\n";
?>

This will produce following result:

dirname is /home/httpd/html

previous Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names