In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "PHP common file operation functions and simple example sharing", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "PHP common file operation functions and simple example sharing" bar!
The most commonly used file operation in PHP is to read and write, today we will mainly talk about read and write functions, and do a page access count function to record the number of visits to a page.
Fopen (): there is no file creation function in PHP. Fopen () function is used to create and open files, which is in the form of resource fopen (string filename, string mode).
Parameter filename is the name of the file opened or created and opened, and parameter mode is the open mode. The specific modes are as follows:
Fread (): can be used to read files in PHP, in the form of string fread (resource handle, int length)
Fread () reads up to length bytes from the file pointer handle and stops reading the file when:
When the length bytes are read
Reached the end of the file (EOF)
(for network streams) 8192 bytes have been read when a packet is available or (after opening the user space stream)
Fgets (): PHP is used to read a line of data from a file and point the file pointer to the next line, in the form of string fgets (resource handle, int length).
Fgets () reads a line from the pointer handle and returns a string of up to (length-1) bytes, stopping reading the file when:
Encounter a newline character
Reached the end of the file (EOF)
(length-1) bytes have been read
If no length parameter is specified, the default is 1024 bytes.
Fwrite (): PHP is used to write a string to a file. It returns the number of characters written on success and false on failure. The function is in the form of int fwrite (resource handle, string data, int length).
Fwrite () writes the contents of the string data to the file pointer handle, with the following parameters:
If the parameter length is specified, writing is stopped when length bytes are written or the data string is written.
Let's take a look at an example: count the visits to the index.php page and write it to the count.html file, and count the visits to the page, so we don't bother with the database > _
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.