Home  >  Article  >  Backend Development  >  PHP file statistics code_PHP tutorial

PHP file statistics code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:18880browse

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>

www.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...
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