? Php $ filecount. dat; if (@ file_exists ($ file) {$ fp @ file ($ file); $ num $ fp [0]; $ ffopen ($ file, w + ); $ number $ num + 1; fputs ($ f, $ number);} else {$ ffopen ($ file, a +); fputs ($ fp, 0 );} @ fclose ($ f );? Hello? $ _ SERVER [REMOTE_ADDR]?, You are the number [? $ Number?] Location counter
$ File = "count. dat ";
If (@ file_exists ($ file )){
$ Fp = @ file ($ file );
$ Num = $ fp [0];
$ F = fopen ($ file, "w + ");
$ Number = $ num + 1;
Fputs ($ f, $ number );
} Else {
$ F = fopen ($ file, "a + ");
Fputs ($ fp, "0 ");
}
@ Fclose ($ f );
?>
Hello , You are [ ] Guest
Encapsulated
Class Counter {
Function addnumber (){
// Multi-user function addnumber ($ user) {// prompt: you can use the ID to count multiple users (multi-page), for example, $ c = new Counter; $ c-> addnumber ($ id );
$ File = "count. dat ";
// Multiple users (page) $ file = $ user. ". dat ";
If (@ file_exists ($ file )){
$ Fp = @ file ($ file );
$ Num = $ fp [0];
$ F = fopen ($ file, "w + ");
$ Number = $ num + 1;
Fputs ($ f, $ number );
} Else {
$ F = fopen ($ file, "a + ");
Fputs ($ fp, "0 ");
}
@ Fclose ($ f );
Print ("Hello $ _ SERVER [" REMOTE_ADDR "], you are the [$ number] guest on this site ");
}
}
Call
Eg. php
$ Co = new Conter;
$ Co-> addnumber (); // count a single user
$ Co-> addnumber ($ id); // multi-user (page) count. the ID here can be the user id that matches the record in your database, or you can remove PHP_SELF from the directory, haha, put a counter directory separately. each page (user) has its own name. dat file to record his
Page access Volume ~, You can also do simple things ~
?>