PHP Files Functions

PHP Error Functions
PHP JSON Functions

On this page, you will find the functions of PHP used to manipulate and process the files. These functions are part of the core language hence, no package installation is required.

The behavior of these functions may vary depending on the php.ini file.

Note that, on Unix, a forward slash (/) is used as the directory separator and on Windows, both forward-slash (/) and backslash (\) can be used.

basename()Returns the filename component of a path
chgrp()Change the file group
chmod()Change the file mode
chown()Change the file owner
clearstatcache()Clear the file status cache
copy()Copy a file
delete()See unlink()
dirname()Returns the directory name component of a path
disk_free_space()Returns the free space of a filesystem or disk
disk_total_space()Returns the total size of a filesystem or disk
diskfreespace()Alias of disk_free_space()
fclose()Close an open file
feof()Check if the “end-of-file” (EOF) has been reached for an open file
fflush()Flushe buffered output to an open file
fgetc()Returns a single character from an open file
fgetcsv()Returns a line from an open CSV file
fgets()Returns a line from an open file
fgetss()Deprecated from PHP 7.3. Returns a line from an open file – stripped from HTML and PHP tags
file()Read a file into an array
file_exists()Check whether or not a file or directory exists
file_get_contents()Read a file into a string
file_put_contents()Write data to a file
fileatime()Returns the last access time of a file
filectime()Returns the last change time of a file
filegroup()Returns the group ID of a file
fileinode()Returns the inode number of a file
filemtime()Returns the last modification time of a file
fileowner()Returns the user ID (owner) of a file
fileperms()Returns the file’s permissions
filesize()Returns the file size
filetype()Returns the file type
flock()Lock or releases a file
fnmatch()Match a filename or string against a specified pattern
fopen()Open a file or URL
fpassthru()Read from the current position in a file – until EOF, and writes the result to the output buffer
fputcsv()Format a line as CSV and writes it to an open file
fputs()Alias of fwrite()
fread()Read from an open file (binary-safe)
fscanf()Parse input from an open file according to a specified format
fseek()Seeks in an open file
fstat()Returns information about an open file
ftell()Returns the current position in an open file
ftruncate()Truncate an open file to a specified length
fwrite()Write to an open file (binary-safe)
glob()Get an array of filenames/directories matching a specified pattern
is_dir()Check whether a file is a directory
is_executable()Check whether a file is executable
is_file()Check whether a file is a regular file
is_link()Check whether a file is a link
is_readable()Check whether a file is readable
is_uploaded_file()Check whether a file was uploaded via HTTP POST
is_writable()Check whether a file is writable
is_writeable()Alias of is_writable()
lchgrp()Change the group ownership of a symbolic link
lchown()Change the user ownership of a symbolic link
link()Creates a hard link
linkinfo()Returns information about a hard link
lstat()Returns information about a file or symbolic link
mkdir()Creates a directory
move_uploaded_file()Move 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()Close a pipe opened by popen()
popen()Opens a pipe
readfile()Read a file and writes it to the output buffer
readlink()Returns the target of a symbolic link
realpath()Returns the absolute pathname
realpath_cache_get()Get real path cache entries
realpath_cache_size()Get real path cache size
rename()Rename a file or directory
rewind()Rewind a file pointer
rmdir()Remove an empty directory
set_file_buffer()Alias of stream_set_write_buffer(). Sets the buffer size for write operations on the given file
stat()Returns information about a file
symlink()Creates a symbolic link
tempnam()Creates a unique temporary file
tmpfile()Creates a unique temporary file
touch()Sets access and modification time of a file
umask()Changes file permissions for files
unlink()Deletes a file
PHP File Functions
PHP Error Functions
PHP JSON Functions
en English
Scroll to Top