(PHP 4, PHP 5, PHP 7, PHP 8) dirname — Returns a parent directory's path Descriptiondirname(string
Caution On Windows, dirname() assumes the currently set codepage, so for it to see the correct directory name with multibyte character paths, the matching codepage must be set. If On other systems, dirname() assumes Parameterspath A path. On Windows, both slash ( levels The number of parent directories to go up. This must be an integer greater than 0. Return Values Returns the path of a parent directory. If there are no slashes in Caution Be careful when using this function in a loop that can reach the top-level directory as this can result in an infinite loop.
Changelog
ExamplesExample #1 dirname() example
The above example will output something similar to: /etc / (or \ on Windows) . C:\ /usr See Also
tapken at engter dot de ¶ 20 years ago
tobylewis at mac dot com ¶ 17 years ago
joe dot naylor at gmail dot com ¶ 13 years ago
klugg this-is-junk at tlen dot pl ¶ 17 years ago
ts at dev dot websafe dot pl ¶ 14 years ago
Tom ¶ 14 years ago
hans111 at yahoo dot com ¶ 15 years ago
soywiz at hotmail dot com ¶ 18 years ago
bobray at softville dot com ¶ 3 years ago
nhl261 at yahoo dot com ¶ 11 years ago
frederikreiss at gmx dot de ¶ 9 years ago
Xedecimal at gmail dot com ¶ 15 years ago
Anonymous ¶ 14 years ago
legolas558 dot sourceforge comma net ¶ 16 years ago
rudecoder at yahoo dot com ¶ 19 years ago
ken dot forslund at hp dot com ¶ 13 years ago
minimalist at intelligence dot com ¶ 10 years ago
webyazilimci84 at gmail dot com ¶ 12 years ago
subzey at immelman dot ru ¶ 12 years ago
Zingus J. Rinkle ¶ 15 years ago
Holger Th?lking ¶ 17 years ago
is_dir ($file)) { dave at corecomm dot us ¶ 19 years ago
andrey at php dot net ¶ 19 years ago
Yousef Ismaeil Cliprz ¶ 9 years ago
qeremy (!) gmail ¶ 6 years ago
function dirname_with_levels($path, $levels = 1) { renich at woralelandia dot com ¶ 17 years ago
|