Principle: & nbsp; 1. the first user browses a page. 2. the number of times the server program reads the page from the database or file. 3. store the number of times and send it back to the first user. 4. the second user browsed a page. 5. the number of times the server program reads the page from the database or file. 6. The principle of SyntaxHighlighter. all is as follows:
1. the first user browses a page.
2. the number of times the server program reads the page from the database or file.
3. store the number of times and send it back to the first user.
4. the second user browsed a page.
5. the number of times the server program reads the page from the database or file.
6. store the number of times and send it back to the second user.
Functions to be understood:
Fopen () open a file
Filesize () to get the file size
Fseek () move file pointer
Fgets () obtains the row content of the file pointer.
Fputs () writes the string as the position of the file pointer.
Fclose () close the file
File_exists () to determine whether a file exists
Exec () executes external programs
The simplest calculator:
Visitor counter prototype
/*
(C) 1998 David W. Bettis
Here is the copyright information
*/
$ CounterFile = "counter.txt ";
# Here is the definition counter file
Function displayCounter ($ counterFile ){
$ Fp = fopen ($ counterFile, "rw ");
# Open a file and use the read/write method
$ Num = fgets ($ fp, 5 );
# Obtain the current number
$ Num + = 1;
# Add 1
Print "you are the". "$ num". "bit boring ";
Exec ("rm-rf $ counterFile ");
Exec ("echo $ num> $ counterFile ");
# The Method of laziness. do not use fputs for writing.
}
If (! File_exists ($ counterFile )){
Exec ("echo 0> $ counterFile ");
} # If the recorder file does not exist, create it and set the content to 0.
DisplayCounter ($ counterFile );
?>
Php (as the mainstream development language) is a relatively simple version:
# No copyright, so easy
$ Fp = fopen ("counter.txt", "r + ");
Flock ($ fp, 3 );
# Open the recorder file and lock it
$ Fsize = filesize ("count.txt ");
$ Count = fgets ($ fp, $ fsize + 1 );
$ Count ++;
# Obtain the digital and add one
Fseek ($ fp, 0 );
Fputs ($ fp, $ count );
Fclose ($ fp );
# Writing new digital data into a file
Echo "you are the $ count visitor ";
?>
Php (as the mainstream development language) stenographer graphic version:
I will not elaborate on creating 10 images and concatenating numbers with pictures.
Fake Image: 0.gif ~ 9. gif
... $ Count is the obtained value.
$ Strcount = strval ($ count );
$ Strcount = chop ($ strcount );
$ Countlen = $ strlen ($ strcount );
$ Shtml = "";
For ($ I = 0; $ I <$ countlen; $ I ++ ){
$ Shtml. = "$ shtml. = $ strcount [$ I];
$ Shtml. = ". gif> ";
}
Echo $ shtml;
?>
Php database version:
Use the SQL calculator to create a table first
Create table counter
(
Counter int not null,
Id
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.