Home > Backend Development > PHP Tutorial > An example of php website access statistics code

An example of php website access statistics code

WBOY
Release: 2016-07-25 08:59:51
Original
1710 people have browsed it
Introducing a code written in PHP to count website visits. The data is saved in the local file count3.dat and called with js in the page. Friends in need can refer to it.

1. Statistics page count.php

<?php
/**
 * 网站访问统计
 * edit bbs.it-home.org
*/
function pageVisitCount(){
    $count= "count3.dat";
    $num= @file_get_contents($count);
    if ($fp= fopen($count,"w+")){
    flock($fp,LOCK_EX);
    $num++;
    fwrite($fp,$num);
    flock($fp,LOCK_UN);
    }
    return $num;
    }

    echo pageVisitCount();
?>
Copy after login

2. Page call

Copy after login


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template