In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces what are the application skills of each function in the operation of PHP files, and the content is very detailed. Interested friends can refer to it and hope to be helpful to you.
PHP language has a wide range of applications, such as the flexible use of PHP language to achieve our needs in the operation of files. Let's take a look at the usage of functions related to PHP file operations.
1. Open file: fopen ("file name", "mode")
Mode:
R: read only
Ringing: read / write
W: write only. Open and empty the contents of the file. If the file does not exist, create the file.
Read / write. Open and empty the contents of the file. If the file is not saved, the file is created.
A: append. Open and write to the end of the file. If the file does not exist, a new file is created.
Read / append. Keep the contents of the file by writing to the end of the file.
two。 Close the file: fclose ()
For example:
< ? $file=fopen("test.txt","r"); //some code be executed fclose=($file); ?>3. Check if the end of the file has been reached: feof ()
For example: if (feof ($file)) {echo "end of file";}
4. Read the file line by line: fgets ()
For example:
File=fopen ("test.txt", "r"); while (! feof ($file)) {echo fgets ($file). "
< br/>";} fclose ($file)
5. Read the file character by character: fgetc ()
6. Whether the file exists: file_exists (); return true if it exists, false otherwise
7. Read the file into an array: $array=file ("text.txt"), $array [0] is the * * line text, and so on. If you want to flip the entire array, for example:
$arr=array_reverse ($array)
Then * one line of text is $arr [0].
To get the number of rows in the array $array, use $num=count ($array)
To determine that the text database is not empty, use: if ($num > 0) {}
Calculate the total number of pages: $total=ceil ($num/$pagesize) $pagesize is the number of messages displayed per page.
Calculate the record number of * displayed on the current page: $number= ($page-1) * $pagesize
Use "" as a delimiter to separate the data for each $number unit in the array $arr and assign this data to the array $rom
For ($iSuppli
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.