PHP dirname()Function


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual

Definition and Usage

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

Syntax

dirname(path)

Parameters Description
path Required. Specifies the path to check.


Examples

<?php
echo dirname("c:/testweb/home.php") . "<br />";
echo dirname("/testweb/home.php");
?>

The above code will output:

c:/testweb
/testweb


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions