PHP Filesystem functions

Quick reference to the filesystem functions of PHP.

Directory functions
Function Returns Does what
chdir(dir) Boolean Makes "dir" the current working directory
closedir([dir_handle]) Nothing Closes "dir_handle" directory or cwd
dir(dir [, context]) Object Returns object representation of "dir"
getcwd() String Returns name of cwd (current working directory)
opendir(path [, context]) Integer Opens "path" and returns dir_handle for it
readdir([dir_handle]) String Returns next name in "dir_handle" directory or cwd
rewinddir([dir_handle]) Nothing Makes "dir_handle" or cwd point to beginning of directory
scandir(dir [, sort order [, context]) Array Lists contents of "dir". Default ascending ("0-9").
dirname(path) String Returns directory name from "path"
disk_free_space(dir) Float Returns free space in "dir" filesystem
disk_total_space(dir) Float Returns total volume of "dir" filesystem
is_dir(filename) Boolean Returns true if "filename" is a directory
mkdir(path, [, mode [, recursive [, context]]]) Boolean Creates directory at "path". Mode default 0777
rmdir(dir [, context]) Boolean Deletes directory "dir"
File functions
Function Returns Does what
basename(path [, suffix]) String Returns filename from "path"
chgrp(file, group) Integer Changes "group" for "file"
chmod(file, mode) Integer Changes "mode" for "file"
chown(file, user) Boolean Makes "user" the owner of "file"
clearstatcache([clear_realpath [, file]]) Nothing Clears file stat cache
copy(from, to [, context]) Boolean Copies file "from", "to"
fclose(handle) Boolean Closes the file with "handle"
feof(handle) Boolean Returns true on eof for file with "handle"
fgetc(handle) String Returns next character from file with "handle"
fgetcsv(handle [, length [, delimiter [, enclosure [, escape]]]]) Array Returns next line as array from file with "handle"
fgets(handle [, length]) String Reads line of "length" (-1 byte) from file with "handle"
fgetss(handle [, length [, tags]) String As fgets(), but removes PHP+HTML tags not in "tags"
file(file [, flags [, context]]) Array Creates array from "file", each line an element
file_exists(file) Boolean Returns true if "file" exists
file_get_contents(file [, use_inc_path [, context [, offset [, maxlen ]]]] ) String Creates string from "file", from "offset" up to "maxlen" bytes
file_put_contents(file, data [, flags [, context]]) Integer Writes "data" to "file"
fileatime(file) Integer Returns time of last access for "file"
filectime(file) Integer Returns time of last change for "file"
filemtime(file) Integer Returns time of last change for "file"
filegroup(file) Integer Returns group ID for "file" owner
fileinode(file) Integer Returns inode number for "file"
fileowner(file) Integer Returns ID of "file" owner
fileperms(file) Integer Returns permissions for "file"
filesize(file) Integer Returns size of "file"
filetype(file) String Returns type of "file"
flock(handle, operation [, wouldblock]) Boolean Sets/removes lock on file with "handle"
fopen(file, mode [, use_inc_path [, context]]) Integer Opens "file", returns handle
fpassthru(handle) Integer Outputs (rest of) file with "handle"
fputs(handle, string [, length]) Integer Writes "string" up to "length" chracters to file with "handle"
fwrite(handle, string [, length]) Integer Writes "string" up to "length" characters to file with "handle"
fread(handle, length) String Reads "length" characters from file with "handle"
fscanf(handle, format [, ...]) Mixed Parses input with "format" from file with "handle"
fseek(handle , offset [, whence]) Integer Moves internal file pointer "offset" from "whence"
fstat(handle) Array Returns array of information about file with "handle"
ftell(handle) Integer Returns position of internal file pointer
ftruncate(handle, size) Boolean Reduces file with "handle" to "size" (truncates)
highlight_file(file [, return]) Nothing Prints out syntax highlighted code of "file"
show_source(file) Nothing Prints out syntax highlighted code of "file"
is_executable(file) Boolean Returns true if "file" is executable
is_file(file) Boolean Returns true if "file" is a file
is_link(file) Boolean Returns true if "file" is a symlink
is_readable(file) Boolean Returns true if "file" is readable
is_writable(file) Boolean Returns true if "file" is writeable
is_writeable(file) Boolean Returns true if "file" is writeable
is_uploaded_file(file) Boolean Returns true if "file" was uploaded with POST
link(target, link) Boolean Creates hard link
linkinfo(path) Integer Returns information about link to "path"
pathinfo(path [, options]) Mixed Returns information about "path"
lstat(file) Array Returns information about "file" or symlink
move_uploaded_file(file, destination) Boolean Moves uploaded "file" to "destination"
pclose(handle) Integer Closes "handle" to pipe opened with popen()
popen(command, mode) Integer Opens pipe by forking "command". Returns handle
readfile(file [, use_inc_path [, context]]) Integer Reads and outputs "file"
readlink(path) String Returns target of symlink
realpath(path) String Returns canonicalized "path"
rename(file, new_name [, context]) Boolean Renames "file" to "new_name"
rewind(handle) Boolean Makes "handle" point to beginning of file
set_file_buffer(handle, bytes) Integer Set write file buffer size to "bytes"
stream_set_write_buffer(handle, bytes) Integer Set write file buffer size to "bytes"
stat(file) Array Returns information about "file"
symlink(file, link) Boolean Creates "link" symlink to "file"
tempnam(directory, prefix) String Creates unique temporary filename in "directory"
tmpfile() Integer Creates temporary file, returns handle
touch(file [, time]) Boolean Marks "file" as modified on "time"
umask([mask]) Integer Changes current umask to "mask". Default 0777
unlink(file [, context]) Boolean Deletes "file"