PHP dirname() Function

Definition

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

Syntax

PHP dirname() Function has the following syntax.

dirname(path)

Parameter

ParameterIs RequiredDescription
pathRequired.Path to check

Return

PHP dirname() Function returns the directory name from a path.

Example


<?php
echo dirname("c:/test/home.php") . "\n";
echo dirname("/test/home.php");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions