The Filesystem functions allow you to access and manipulate the file system.
Filesystem functions are part of the core of PHP. No installation is required to use these functions.
The behavior of Filesystem functions is affected by settings in php.ini.
Filesystem configuration options:
name | default | describe | Can be changed |
---|---|---|---|
allow_url_fopen | "1" | Allow fopen()-type functions to use URLs. (Available after PHP version 4.0.4) | PHP_INI_SYSTEM |
user_agent | NULL | Defines the user agent sent by PHP. (Available after PHP version 4.3) | PHP_INI_ALL |
default_socket_timeout | "60" | Sets the default timeout (in seconds) for socket streams. (Available after PHP version 4.3) | PHP_INI_ALL |
from | "" | Define the password for anonymous FTP (your email address). | PHP_INI_ALL |
auto_detect_line_endings | "0" | When set to "1", PHP will check whether line endings in data obtained through fgets() and file() conform to Unix, MS-Dos, or Mac conventions. (Available after PHP version 4.3) | PHP_INI_ALL |
When specifying paths on Unix platforms, the forward slash (/) is used as the directory separator. On Windows platforms, both forward slash (/) and backslash () can be used.
function | describe |
---|---|
basename() | Returns the filename portion of the path. |
chgrp() | Change filegroup. |
chmod() | Change file mode. |
chown() | Change file owner. |
clearstatcache() | Clear file status cache. |
copy() | Copy the file. |
delete() | See unlink() or unset() |
dirname() | Returns the directory name portion of the path. |
disk_free_space() | Returns the free space of the directory. |
disk_total_space() | Returns the total disk capacity of a directory. |
diskfreespace() | Alias for disk_free_space(). |
fclose() | Close open files. |
feof() | Tests whether the file pointer has reached the end of the file. |
fflush() | Flushes buffered output to an open file. |
fgetc() | Return characters from an open file. |
fgetcsv() | Parse a line from the open file and verify the CSV fields . |
fgets() | Returns a line from an open file. |
fgetss() | Returns a line from an open file, filtering out HTML and PHP tags. |
file() | Read the file into an array. |
file_exists() | Check if the file or directory exists. |
file_get_contents() | Read the file into a string. |
file_put_contents() | Write a string to a file. |
fileatime() | Returns the last access time of the file. |
filectime() | Returns the last modification time of the file. |
filegroup() | Returns the group ID of the file. |
fileinode() | Returns the inode number of the file. |
filetime() | Returns the last modification time of the file contents. |
fileowner() | Returns the user ID (owner) of the file. |
fileperms() | Returns the file's permissions. |
filesize() | Returns the file size. |
filetype() | Returns the file type. |
flock() | Lock or release files. |
fnmatch() | Matches filenames or strings based on a specified pattern. |
fopen() | Open a file or URL. |
fpassthru() | Reads data from an open file until the end of file (EOF) and writes the results to the output buffer. |
fputcsv() | Format the rows to CSV and write to an open file. |
fputs() | Alias for fwrite(). |
fread() | Read the open file. |
fscanf() | Parses the input according to the specified format. |
fseek() | Locate within an open file. |
fstat() | Returns information about an open file. |
ftell() | Returns the current position in the open file. |
ftruncate() | Truncate an open file to the specified length. |
fwrite() | Write to an open file. |
glob() | Returns an array containing filenames/directories matching the specified pattern. |
is_dir() | Determine whether the file is a directory. |
is_executable() | Determine whether the file is executable. |
is_file() | Determine whether the file is a regular file. |
is_link() | Determine whether the file is a connection. |
is_readable() | Determine whether the file is readable. |
is_uploaded_file() | Determine whether the file was uploaded via HTTP POST. |
is_writable() | Determine whether the file is writable. |
is_writeable() | Alias for is_writable(). |
lchgrp() | Change the group ownership of a symbolic link. |
lchown() | Change user ownership of symbolic links. |
link() | Create a hard link. |
linkinfo() | Returns information about a hard link. |
lstat() | Returns information about a file or symbolic link. |
mkdir() | Create directory. |
move_uploaded_file() | Move uploaded files to a new location. |
parse_ini_file() | Parse a configuration file. |
parse_ini_string() | Parse a configuration string. |
pathinfo() | Returns information about the file path. |
pclose() | Close the process opened by popen(). |
popen() | Open a process. |
readfile() | Read a file and write to the output buffer. |
readlink() | Returns the target of the symbolic link. |
realpath() | Returns the absolute pathname. |
realpath_cache_get() | Return cache entry. |
realpath_cache_size() | Returns the cache size. |
rename() | Rename a file or directory. |
rewind() | Rewind the position of the file pointer. |
rmdir() | Delete empty directories. |
set_file_buffer() | Sets the buffer size for open files. |
stat() | Returns information about the file. |
symlink() | Create a symbolic link. |
tempnam() | Create a unique temporary file. |
tmpfile() | Create a unique temporary file. |
touch() | Set access and modification times for files. |
umask() | Change the file permissions of a file. |
unlink() | Delete files. |