Code example:
php file statistics code
$countfile = "num.txt";
//The file to define the counter is count.txt in the current directory, and then we should test whether the file can Open
if (($fp = fopen($countfile, "r ")) == false) { //Open the file in read-write mode, exit if it cannot be opened
printf ("Failed to open file %s !",$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;
fclose ($fp);
//Close the current file
$ fp = fopen($countfile, "w ");
//Open the file in overwrite mode
fwrite ($fp,$count);
//Write the new data after adding 1
fclose ($fp);
//And close the file
}
//The code for converting $count to picture mode
$fp = fopen ($countfile, "r"); //Open the file in read-only mode
$array_count = 1; //Define a variable representing the position of the array element. Use
while (! feof($fp)) {
$current_number = fgetc ($fp);
$counter_array[$array_count] = $current_number;
$array_elements = count ($counter_array);
$array_count = $array_count 1;
}
//Display Code
echo ("
Welcome, No."); for ($array_id = 1;$array_id < $array_elements; $array_id) { echo ("") ; } echo ("Guests |
");
?>
< /HTML>
http://www.bkjia.com/PHPjc/486222.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486222.htmlTechArticleCode example: HTML HEAD TITLEphp file statistics code/TITLE /HEAD BODY ?PHP $countfile = "num.txt "; //The file to define the counter is count.txt in the current directory, then we should...