Home  >  Article  >  Backend Development  >  PHP File Function Manual Overview_PHP Tutorial

PHP File Function Manual Overview_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:33:13722browse

For

From now on I will record and share the relevant knowledge I have learned about PHP file processing! I think any programming language will inevitably have to be related to We deal with the file system, so there are a lot of functions related to file processing in PHP. In the morning, I read the PHP help manual to start recording the learning results, and found that there are more than 80~~. Of course, some of these functions are only available on specific platforms. It is effective. Some functions do not work on WIN.

File processing and string operations, in my opinion, have similar properties. A file is not just a collection of strings! So I put them together and made a simple study. After all, there are too many functions to understand one by one. But does the more you master mean the higher your level? Take a look at it when you have nothing to do. That’s not a bad thing!

Comprehensive list of PHP file functions

basename — Returns the filename portion of the path
chgrp — Changes the group the file belongs to
chmod — Changes the file mode
chown — Changes the owner of the file
clearstatcache — Clears the file status cache
copy — Copy a file
delete — See unlink() or unset()
dirname — Return the directory part of the path
disk_free_space — Return the free space in the directory
disk_total_space — Return the total space of a directory Total disk size
diskfreespace — Alias ​​of disk_free_space()
fclose — Close an open file pointer
feof — Test whether the file pointer reaches the end of the file
fflush — Output the buffered content to a file
fgetc — Read characters from a file pointer
fgetcsv — Read a line from a file pointer and parse CSV fields
fgets — Read a line from a file pointer
fgetss — Read from a file pointer Take a line and filter out HTML tags
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 to the file
file — Put the entire The file is read into an array
fileatime — Get the last access time of the file
filectime — This PHP file function gets the inode modification time of the file
filegroup — Get the group of the file
fileinode — Get the file’s inode
filemtime — Get file modification time
fileowner — Get file owner
fileperms — Get file permissions
filesize — Get file size
filetype — Get file type
flock — Lightweight advisory file locking
fnmatch — Match filenames with patterns
fopen — Open a file or URL
fpassthru — Output all remaining data at the file pointer
fputcsv — Format rows to CSV and write Input file pointer
fputs — Alias ​​for fwrite()
fread — Read file (safe for binary files)
fscanf — Format input from file
fseek — Position in file pointer
fstat — Get file information through the opened file pointer
ftell — Return the read/write position of the file pointer
ftruncate — Truncate the file to the given length
fwrite — Write to the file (can Safe for binary files)
glob — Finds file paths matching a pattern
is_dir — This PHP file function determines whether a given filename is a directory
is_executable — determines whether a given filename is executable
is_file — Determines whether the given file name is a normal file
is_link — Determines whether the given file name is a symbolic link
is_readable — Determines whether the given file name is readable
is_uploaded_file — Determines the file Whether it is uploaded through HTTP POST
is_writable — Determine whether the given file name is writable
is_writeable — An alias of is_writable()
link — Establish a hard link
linkinfo — Get information about a connection
lstat — gives information about a file or symbolic link
mkdir — creates a new directory
move_uploaded_file — moves an uploaded file to a new location
parse_ini_file — parses a configuration file
pathinfo — returns a file Path information
pclose — close the process file pointer
popen — open the process file pointer
readfile — output a file
readlink — return the target pointed to by the symbolic link
realpath — return the normalized 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 for 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
unlink — delete files

Of course, there are some PHP file functions as mentioned just now, and it is impossible to use them all. Just remember a few common ones and it will be OK, at least that's what I think. Let’s start from the next section to formally understand the simple use of some of the key functions. The first file processing function we see in wordpress is dirname: require_once( dirname(__FILE__) . ‘/wp-load.php’ ); basically in WP, the file path uses an absolute path!


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446071.htmlTechArticleFrom now on I will record and share the relevant knowledge I have learned about PHP file processing! I want to Any programming language inevitably has to deal with the file system, so in P...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn