PHP Filesystem



Introduction to PHP Filesystem

The Filesystem function allows you to access and manipulate the file system.


Installation

The Filesystem function is an integral part of the PHP core. No installation is required to use these functions.


Runtime Configuration

The behavior of the Filesystem functions is affected by settings in php.ini.

Filesystem configuration options:

NameDefaultDescriptionCan be changed
allow_url_fopen"1"Allow fopen()-type function to use URL. (Available from PHP version 4.0.4) PHP_INI_SYSTEM
user_agentNULLDefine the user agent sent by PHP. (Available after PHP version 4.3) PHP_INI_ALL
default_socket_timeout"60"Set the default timeout based on socket stream Time (seconds). (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 via fgets() And whether the line ending symbols in the data obtained by file() conform to the convention of Unix, MS-Dos or Mac. (Available from PHP version 4.3) PHP_INI_ALL


Unix / Windows Compatibility

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.


PHP 5 Filesystem Function

Returns the filename portion of the path. chgrp()Change the file group. chmod()Change the file mode. chown()Change the file owner. clearstatcache()Clear the file status cache. Copy the file. delete()See unlink() or unset()Return the directory name part 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(). Close the open file. Test whether the file pointer has reached the end of the file. fflush() Flushes buffered output to the open file. Return characters from the open file. fgetcsv()Parse a line from the open file and verify the CSV field. Returns a line from the open file. fgetss()Returns a line from an open file, filtering out HTML and PHP tags. Read the file into an array. Check whether the file or directory exists. Read the file into a string.
#FunctionDescription
##basename( )
copy()
dirname()
fclose()
feof()
fgetc()
fgets()
file()
file_exists()
file_get_contents()
file_put_contents()Write the string to the 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.
filemtime()Returns the last modification time of the file content.
fileowner()Returns the user ID (owner) of the file.
fileperms()Returns the permissions of the file.
filesize()Returns the file size.
filetype() Returns the file type.
flock()Lock or release the file.
fnmatch() Matches file names or strings based on the specified pattern.
fopen()Open a file or URL.
fpassthru()Read data from the open file until the end of file (EOF), and write the result to the output buffer.
fputcsv()Format 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 in the open file.
fstat() Returns information about an open file.
ftell()Returns the current position in the open file.
ftruncate()Truncate the open file to the specified length.
fwrite()Write to the open file.
glob()Returns an array containing file names/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 is uploaded through 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 the user ownership of a symbolic link.
link()Create a hard link.
linkinfo() Returns information about a hard link.
lstat() Returns information about the file or symbolic link.
mkdir()Create a directory.
move_uploaded_file()Move the uploaded file 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 it to the output buffer.
readlink()Returns the target of the symbolic link.
realpath() Returns the absolute path name.
realpath_cache_get()Returns the 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()Set the buffer size of the opened file.
stat() Returns information about the file.
symlink()Create a symbolic link.
tempnam()Creates a unique temporary file.
tmpfile()Creates a unique temporary file.
touch()Set the access and modification time of the file.
umask()Change the file permissions of the file.
unlink()Delete the file.