Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

PHP 5 Filesystem function


May 11, 2021 PHP


Table of contents


PHP 5 Filesystem function

How do I access PHP's file system? Use PHP's file system function: Filesystem function!


Introduction to PHP Filesystem

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


Installation

The Filesystem function is part of the PHP core. These functions can be used without installation.


Runtime configuration

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

Filesystem configuration options:

name default describe Changeable
allow_url_fopen "1" Allow the FOPEN () - Type function to use the URL.(Apply after the PHP version 4.0.4) PHP_INI_SYSTEM
user_agent NULL Define the user agent sent by PHP.(Apply after the PHP version 4.3) PHP_INI_ALL
default_socket_timeout "60" Set the default timeout (seconds) based on the Socket stream.(Apply after the PHP version 4.3) PHP_INI_ALL
from "" Define the password of an anonymous FTP (your email address). PHP_INI_ALL
auto_detect_line_endings "0" When set to "1", PHP will check the end symbols in the data acquired by fgets () and file () in accordance with UNIX, MS-DOS or Mac habits.(Apply after the PHP version 4.3) PHP_INI_ALL


Unix /Windows compatibility

When a path is specified on the Unix platform, the forward slash (/) is used as a directory separator. On the Windows platform, both the forward slash (/) and the backslash can be used.


PHP 5 Filesystem function

function describe
basename() Returns the file name part in the path.
chgrp() Change the file group.
chmod() Change file mode.
chown() Change the file owner.
clearstatcache() Clear the file status cache.
copy() Copy the file.
delete() See unlink () or unset ()
dirname() Returns the directory name part in the path.
disk_free_space() Returns the available space of the directory.
disk_total_space() Returns a total disk total disk.
diskfreespace() The alias of Disk_Free_Space ().
fclose() Close the open file.
feof() Whether the test file pointer has arrived at the end of the file.
fflush() Refresh the buffer output to the open file.
fgetc() Returns the character from the open file.
fgetcsv() Resolve a line from the open file, check CSV field
fgets() Return from the open file.
fgetss() Return from the open file and filter out the HTML and PHP tags.
file() Read files into an array.
file_exists() Check if the file or directory exists.
file_get_contents() Read files into strings.
file_put_contents() Write a string into 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.
filemtime() Returns the last modification time of the file content.
fileowner() Returns the user ID of the file (owner).
fileperms() Returns the permissions of the file.
filesize() Returns the file size.
filetype() Returns the file type.
flock() Lock or release files.
fnmatch() The file name or string is matched according to the specified mode.
fopen() Open a file or URL.
fpassthru() Read data from the open file until the end of the file (EOF), and the result is built to the output.
fputcsv() Format it into CSV and write it in an open file.
fputs() The alias of fwrite ().
fread() Read the open file.
fscanf() An input is parsed according to the specified format.
fseek() Locate in the open file.
fstat() Returns information about an open file.
ftell() Returns the current location in the open file.
ftruncate() Truncate the open file to the specified length.
fwrite() Write the file opened.
glob() Returns an array containing a file name / directory that matches the specified mode.
is_dir() The judgment file is a directory.
is_executable() The judgment is executable.
is_file() The judgment is whether the file is a regular file.
is_link() It is determined whether the file is connected.
is_readable() Determine if the file is readable.
is_uploaded_file() It is determined whether the file is uploaded by HTTP POST.
is_writable() The judgment file is written.
is_writeable() IS_WRITABLE () alias.
lchgrp() Change the group ownership of the symbolic connection.
lchown() Change the user ownership of the symbolic connection.
link() Create a hard connection.
linkinfo() Returns information about a hard connection.
lstat() Returns information about files or symbolic connections.
mkdir() Create a directory.
move_uploaded_file() Move uploaded files to a new location.
parse_ini_file() Analysis of a configuration file.
parse_ini_string() Parrse a configuration string.
pathinfo() Returns information about the file path.
pclose() Closing 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 connection.
realpath() Returns the absolute path name.
realpath_cache_get() Returns the cache entry.
realpath_cache_size() Returns the cache size.
rename() Rename the file or directory.
rewind() Reverse the location of the file pointer.
rmdir() Delete empty directories.
set_file_buffer() Set the buffer size that has been opened.
stat() Returns information about the file.
symlink() Create a symbolic connection.
tempnam() Create a unique temporary file.
tmpfile() Create a unique temporary file.
touch() Set the access and modification time of the file.
umask() Change file permissions for files.
unlink() Delete Files.

That's the whole story of the Filesystem function, and in the next section you'll learn about the Filter function!