Home >Backend Development >PHP Tutorial >Introduction and usage examples of filesystem file system functions in php_PHP tutorial
basename — Returns the filename part of the path
dirname — Returns the directory part of the path
Example:
Note: If the file name ends with the correct suffix, this part will also be removed.
chgrp — Change the group the file belongs to
chown — Change the owner of the file
chmod — Change the file mode
Example:
if(copy('index.php', 'index.php.bak')){
echo 'copy success';
}
?>
//In the current directory The index.php.bak file is saved under
delete — see unlink or unset
unlink — delete file
disk_free_space — Returns the free space in a directory
disk_total_space — Returns the total disk size of a directory
diskfreespace — Alias for disk_free_space
fopen — Open a file or URL
fgets — Read a line from the file pointer
feof — Test whether the file pointer has reached the end of the file
fread — Read a file (safe for binary files )
fwrite — write to a file (safe for binary files)
fclose — close an open file pointer
fgetc — Read characters from a file pointer
fgetcsv — Read a line from a file pointer and parse CSV fields
fgetss — Read a line from a file pointer and filter out HTML tags
fputcsv — Format rows to CSV and write to file pointer
fputs — alias for fwrite
file_exists — Check if a file or directory exists
file_get_contents — Read the entire file into a string
file_put_contents — Write a string into the file
file — Read the entire file into an array
fileatime — Get the last access time of the file
filectime — Get the inode modification time of the file
filegroup — Get the group of the file
fileinode — Get the inode of the file
filemtime — Get the file modification time
fileowner — Get the owner of the file
fileperms — Get the permissions of the file
filesize — Get the file size
filetype — Get the file type
flock — Lightweight advisory file locking
fnmatch — Match filenames with patterns
fflush — Output buffer contents to a file
fpassthru — Output all remaining data at the file pointer
fscanf — From Format input in the file
fseek — locate the file pointer
fstat — obtain file information through the opened file pointer
ftell — return the read/write position of the file pointer
ftruncate — truncate the file to given length
glob — Find file paths matching pattern
is_dir — Determines whether the given file name is a directory
is_executable — Determines whether the given file name is executable
is_file — Determines whether the given file name is a normal file
is_link — Determines whether the given file name is executable Determine whether the file name is a symbolic link
is_readable — Determine whether the given file name is readable
is_uploaded_file — Determine whether the file was uploaded via HTTP POST
is_writable — Determine whether the given file name is writable
is_writeable — Alias of is_writable
Description: The above functions are used to determine whether the file or directory meets the corresponding conditions and return TRUE or FALSE.
lchgrp — Changes group ownership of symlink
lchown — Changes user ownership of symlink
link — Create a hard link
linkinfo — Get information about a connection
lstat — Give a file or symbol Connection information
mkdir — Create a new directory
move_uploaded_file — Move the uploaded file to a new location
parse_ini_file — Parse a configuration file
pathinfo — Return file path information
pclose — Close the process file pointer
popen — Open process file pointer
readfile — Output a file
readlink — Return the target pointed to by the symbolic link
realpath — Return the canonical absolute path name
rename — Rename a file or Directory
rewind — Rewind the position of the file pointer
rmdir — Delete the directory
set_file_buffer — Alias of stream_set_write_buffer
stat — Give information about the file
symlink — Create a symbolic link
tempnam — Create a file with a unique file name
tmpfile — Create a temporary file
touch — Set the access and modification time of the file
umask — Change the current umask
clearstatcache — Clear the file status cache