How to implement statistics on the number of people online on a website in php, number of people online in php_PHP tutorial

PHP中文网
Release: 2016-07-13 09:54:07
Original
1048 people have browsed it

How to use php to count the number of people online on a website, how many people are online in php

The example in this article describes how to use php to count the number of people online on a website. Share it with everyone for your reference. The specific implementation method is as follows:

 $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;
?>
Copy after login

The above is how PHP implements statistics on the number of people online on the website. The number of people online in PHP_PHP tutorial. For more related content, please pay attention to the PHP Chinese website (www.php.cn) !

http://www.bkjia.com/PHPjc/998558.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/998558.htmlTechArticlephp method to realize the statistics of the number of people online on the website, the number of people online in php The example in this article describes the method of using PHP to count the number of people online on a website. Share it with everyone for your reference. The specific implementation method is as follows...


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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!