PHP 8.5.0 Beta 3 available for testing

Filesystem Functions

See Also

For related functions, see also the Directory and Program Execution sections.

For a list and explanation of the various URL wrappers that can be used as remote files, see also Supported Protocols and Wrappers.

Table of Contents

  • basename β€” Returns trailing name component of path
  • chgrp β€” Changes file group
  • chmod β€” Changes file mode
  • chown β€” Changes file owner
  • clearstatcache β€” Clears file status cache
  • copy β€” Copies file
  • delete β€” See unlink or unset
  • dirname β€” Returns a parent directory's path
  • disk_free_space β€” Returns available space on filesystem or disk partition
  • disk_total_space β€” Returns the total size of a filesystem or disk partition
  • diskfreespace β€” Alias of disk_free_space
  • fclose β€” Closes an open file pointer
  • fdatasync β€” Synchronizes data (but not meta-data) to the file
  • feof β€” Tests for end-of-file on a file pointer
  • fflush β€” Flushes the output to a file
  • fgetc β€” Gets character from file pointer
  • fgetcsv β€” Gets line from file pointer and parse for CSV fields
  • fgets β€” Gets line from file pointer
  • fgetss β€” Gets line from file pointer and strip HTML tags
  • file β€” Reads entire file into an array
  • file_exists β€” Checks whether a file or directory exists
  • file_get_contents β€” Reads entire file into a string
  • file_put_contents β€” Write data to a file
  • fileatime β€” Gets last access time of file
  • filectime β€” Gets inode change time of file
  • filegroup β€” Gets file group
  • fileinode β€” Gets file inode
  • filemtime β€” Gets file modification time
  • fileowner β€” Gets file owner
  • fileperms β€” Gets file permissions
  • filesize β€” Gets file size
  • filetype β€” Gets file type
  • flock β€” Portable advisory file locking
  • fnmatch β€” Match filename against a pattern
  • fopen β€” Opens file or URL
  • fpassthru β€” Output all remaining data on a file pointer
  • fputcsv β€” Format line as CSV and write to file pointer
  • fputs β€” Alias of fwrite
  • fread β€” Binary-safe file read
  • fscanf β€” Parses input from a file according to a format
  • fseek β€” Seeks on a file pointer
  • fstat β€” Gets information about a file using an open file pointer
  • fsync β€” Synchronizes changes to the file (including meta-data)
  • ftell β€” Returns the current position of the file read/write pointer
  • ftruncate β€” Truncates a file to a given length
  • fwrite β€” Binary-safe file write
  • glob β€” Find pathnames matching a pattern
  • is_dir β€” Tells whether the filename is a directory
  • is_executable β€” Tells whether the filename is executable
  • is_file β€” Tells whether the filename is a regular file
  • is_link β€” Tells whether the filename is a symbolic link
  • is_readable β€” Tells whether a file exists and is readable
  • is_uploaded_file β€” Tells whether the file was uploaded via HTTP POST
  • is_writable β€” Tells whether the filename is writable
  • is_writeable β€” Alias of is_writable
  • lchgrp β€” Changes group ownership of symlink
  • lchown β€” Changes user ownership of symlink
  • link β€” Create a hard link
  • linkinfo β€” Gets information about a link
  • lstat β€” Gives information about a file or symbolic link
  • mkdir β€” Makes directory
  • move_uploaded_file β€” Moves an uploaded file to a new location
  • parse_ini_file β€” Parse a configuration file
  • parse_ini_string β€” Parse a configuration string
  • pathinfo β€” Returns information about a file path
  • pclose β€” Closes process file pointer
  • popen β€” Opens process file pointer
  • readfile β€” Outputs a file
  • readlink β€” Returns the target of a symbolic link
  • realpath β€” Returns canonicalized absolute pathname
  • realpath_cache_get β€” Get realpath cache entries
  • realpath_cache_size β€” Get realpath cache size
  • rename β€” Renames a file or directory
  • rewind β€” Rewind the position of a file pointer
  • rmdir β€” Removes directory
  • set_file_buffer β€” Alias of stream_set_write_buffer
  • stat β€” Gives information about a file
  • symlink β€” Creates a symbolic link
  • tempnam β€” Create file with unique file name
  • tmpfile β€” Creates a temporary file
  • touch β€” Sets access and modification time of file
  • umask β€” Changes the current umask
  • unlink β€” Deletes a file
οΌ‹add a note

User Contributed Notes 1 note

up
64
Christian ΒΆ
18 years ago
I just learned that, to specify file names in a portable manner, you DON'T need 'DIRECTORY_SEPARATOR' - just use '/'. This really surprised and shocked me, as until now I typed about a zillion times 'DIRECTORY_SEPARATOR' to stay platform independent - unnecessary. Don't make the same mistake.
To Top