$countfile = "counter.txt";
//The file that defines the counter is written to the counter.txt file in the current directory, and then we should test whether the file can be opened
if (($fp = fopen($countfile, "r+")) == false) {
//Open the file in read-write mode, exit if it cannot be opened
printf ("open file %s failed!",$countfile);
exit;
}
else
{
//If the file can be opened normally, read the data in the file, assuming it is 1
$count = fread ($fp,10);
//Read 10-bit data
$count = $count + 1;
//count++
fclose ($fp);
//Close the current file
$fp = fopen($countfile, "w+");
//Open the file in overwrite mode
fwrite ($fp,$count);
//Write new data after adding 1
fputs($fp,$fg);
//Display counting results
//Number display
echo "Count times: $count
";//Graphic mode count
$fp = fopen ($countfile, "r"); //Open the file in read-only mode
$array_count = 1; //Define a variable that represents the position of the array element, use
below while (! feof($fp)) {
$current_number = fgetc($fp);
$counter_array[$array_count] = $current_number;
$array_elements = count ($counter_array);
$array_count = $array_count + 1;
}
echo "Number of counts:";
for ($array_id = 1;$array_id < $array_elements; ++ $array_id) {
echo "";
}
echo "";fclose ($fp);
//And close the file
}?>
Previous article:PHP registration page code (mysql+php)_PHP tutorial Next article:Read text files and display them on the web page_PHP tutorialStatement of this WebsiteThe 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.cnLatest Articles by Author
2024-10-22 09:46:29 2024-10-13 13:53:41 2024-10-12 12:15:51 2024-10-11 22:47:31 2024-10-11 19:36:51 2024-10-11 15:50:41 2024-10-11 15:07:41 2024-10-11 14:21:21 2024-10-11 12:59:11 2024-10-11 12:17:31Latest IssuesGroup MySQL results by ID for looping over I have a table with flight data in mysql. I'm writing a php code that will group and displ...From 2024-04-06 17:27:5601406