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
  • Returns the location where the file pointer is read/write ftell

    ftell

    Returnsthelocationwh
  • Get file type filetype

    filetype

    Getfiletype
  • Read a line from a file pointer fgets

    fgets

    Readalinefromafilepo
  • Get file information through the opened file pointer fstat

    fstat

    Getfileinformationth
  • Determine whether the given file name is writable is_writable

    is_writable

    Determinewhethertheg
  • Get the inode of the file fileinode

    fileinode

    Gettheinodeofthefile
  • Close process file pointer pclose

    pclose

    Closeprocessfilepoin
  • Returns the file name part in the path basename

    basename

    Returnsthefilenamepa