Ec (2); php image counter Code. Its implementation method is to first save the number to a txt file or database and then read it. Of course, we need to create a 0-9 image. now let's take a look at the statistical code. & lt ;? Php & nbsp; require_once (& quot ;.. incconnect. php & quot;); & nbsp; ClassSit_count {& nbsp; public $ FileNa script ec (2); script
Php image counter Code. Its implementation method is to first save the number to a txt file or database, and then read it. Of course, we need to prepare a 0-9 image. now let's take a look at the statistical code.
Require_once ("../inc/connect. php ");
Class Sit_count {
Public $ FileName = 'count.txt ';
Function Count_add (){
If (file_exists ($ this-> FileName )){
$ Temp = file_get_contents ($ this-> FileName );
$ Array = explode ("=", $ Temp );
If (count ($ Array )! = 2 ){
$ Tmp = 'mytext = '. $ this-> Tcount ();
} Else {
$ Total = $ Array [1] + 1;
$ Tmp = $ Array [0]. '='. $ Total;
}
$ T = @ fopen ($ this-> FileName, 'w ');
If ($ T ){
Fwrite ($ T, $ Tmp );
Fclose ($ T );
}
Mysql_query ("update wk_count set count_bak = count_bak + 1 where id = 1 ");
} Else {
Echo '! File_exists ';
}
}
Function Tcount (){
$ Result = mysql_query ("Select * from wk_count where id = 1") or die (mysql_error ());
$ Rs = mysql_fetch_array ($ result );
Return $ rs ['count _ Bak'];
}
}
$ Tp = new Sit_count;
$ Tp-> Count_add ();
?>
Now let's take a look at the output file of show. php.
$ Count = substr(file_get_contents('count.txt '), 7 );
$ Con_len = strlen ($ count );
For ($ I = $ con_len-1; $ I >=0; $ I --){
Echo "document. write ('');";
}
?>
In this way, our input counter will come out. Pay attention to this. echo "document. write ('');"; must begin with document. write output, because we need to call it in js format below.
The following figure shows how to call the show. php file in txt.html.