★ wanayoo — archive 1999 http://www.php.net/manual/function.dirname.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Filesystem
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Filesystem
* basename
* chgrp
* chmod
* chown
* clearstatcache
* copy
* delete
* dirname
* diskfreespace
* fclose
* feof
* fgetc
* fgetcsv
* fgets
* fgetss
* file
* file_exists
* fileatime
* filectime
* filegroup
* fileinode
* filemtime
* fileowner
* fileperms
* filesize
* filetype
* flock
* fopen
* fpassthru
* fputs
* fread
* fscanf
* fseek
* fstat
* ftell
* ftruncate
* fwrite
* set_file_buffer
* is_dir
* is_executable
* is_file
* is_link
* is_readable
* is_writeable
* link
* linkinfo
* mkdir
* pclose
* popen
* readfile
* readlink
* rename
* rewind
* rmdir
* stat
* lstat
* realpath
* symlink
* tempnam
* touch
* umask
* unlink
Manual: dirname
View the source code for this pageSearch the site



Previous page
 delete
 Updated
Sat, 12 Aug 2000
diskfreespace 
Next page


dirname

(PHP3 , PHP4 )

dirname -- Return directory name component of path

Description

string dirname (string path)

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

On Windows, both slash (/) and backslash (\) are used as path separator character. In other environments, it is the forward slash (/).

Example 1. dirname() example


$path = "/etc/passwd";
$file = dirname($path); // $file is set to "/etc"
      

See also: basename()


User Contributed Notes: dirname


j-emmons@sjca.edu
16-Dec-1999 05:57
It's interesting to note that dirname() does not treat /foo/ as a directory. This means that if you hand it the URI of and address that doesn't specify an index file, like http://www.bar.com/foo/, it will return ""


Examples:

<PRE>
dirname("/foo/index.html"); #returns "/foo" whereas

dirname("/foo/"); #returns ""
</PRE>



 About Notes


Previous page
 delete
 Updated
Sat, 12 Aug 2000
diskfreespace 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.