Directory operations in PHP

PHP has a whole variety of functions for directory operations. Here are a few of the important ones:

  • chdir($dir): Change working directory
  • $dir = getcwd(): Get working directory
  • mkdir($dir, [$permission], [$recursive]): Create a new directory with permission model (in octal) $permission
  • is_dir($directory): Check if path is an actual directory
  • chmod($file, $permission): Change permission of a file/directory with a permission model (also in octal)
  • chgrp($file, $group): Change group ownership of a file/directory
  • chown($file, $name): Change ownership of a file/directory
  • $array = scandir($folder): Return a list of files/directories in the specified folder

Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

Filed Under: PHP File Handling

Tags:

RSSComments (0)

Trackback URL

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.