Home > php教程 > php手册 > php实现统计网站在线人数的方法

php实现统计网站在线人数的方法

WBOY
Release: 2016-06-06 20:04:17
Original
1045 people have browsed it

这篇文章主要介绍了php实现统计网站在线人数的方法,通过获取服务器端网络参数及文本文件读写实现统计在线人数的功能,非常简单实用,需要的朋友可以参考下

本文实例讲述了php实现统计网站在线人数的方法。分享给大家供大家参考。具体实现方法如下:

$val) { $val= trim($val); if ($val != "") { list($when, $seti) = explode("\t", $val); if ($seti ==$ip) { $arr[$key] = $time . "\t" . $seti; $flag = 1; } else { $currentTime = time(); if ($currentTime - $when > 900) { unset($arr[$key]); }else{ $arr[$key]=$val; } } } } if ($flag == 0) { array_push($arr, $time . "\t" . $ip); } $count = count($arr); $str = implode("\r\n", $arr); $str.="\r\n"; writeover($fileCount, $str, 'w', 0); unset($arr); } return $count; } $time = time(); $ip = getIpAddress(); $online_num = count_online_num($time,$ip); echo $online_num; ?>

希望本文所述对大家的php程序设计有所帮助。

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template