Home >Backend Development >PHP Tutorial >How to use php dirname function

How to use php dirname function

藏色散人
藏色散人Original
2019-02-19 15:47:482863browse

php The dirname() function returns the directory part of the path. Its syntax is [dirname(path)]. The parameter path is required and refers to the path to be checked.

How to use php dirname function

php dirname function usage:

php dirname() function syntax

Function: Returns the directory portion of the path.

Syntax:

dirname(path)

Parameters:

path Required. Specifies the path to be checked.

Explanation: The

path parameter is a string containing the full path to a file. This function returns the directory name after removing the file name.

php dirname() function example

<?php
$file = "/phpstudy/WWW/index.php";
echo dirname($file);
?>

Output:

/phpstudy/WWW

This article is an introduction to the PHP dirname function. I hope it will be helpful to friends who need it. Helps!

The above is the detailed content of How to use php dirname function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn