Current Location: Home> Function Categories> dirname

dirname

Return to the directory part in the path
Name:dirname
Category:File system
Programming Language:php
One-line Description:Returns the directory name part in the path.

Example

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">dirname</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"c:/testweb/home.php"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token function">dirname</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"/testweb/home.php"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

Output:

 c:/testweb
/testweb
Similar Functions
  • Find file paths that match patterns glob

    glob

    Findfilepathsthatmat
  • Get the last access time of the file fileatime

    fileatime

    Getthelastaccesstime
  • Returns the location where the file pointer is read/write ftell

    ftell

    Returnsthelocationwh
  • Change the group to which the file belongs chgrp

    chgrp

    Changethegrouptowhic
  • Get the file owner fileowner

    fileowner

    Getthefileowner
  • Delete directory rmdir

    rmdir

    Deletedirectory
  • Synchronize data (but not metadata) to a file fdatasync

    fdatasync

    Synchronizedata(butn
  • Check if the file or directory exists file_exists

    file_exists

    Checkifthefileordire