PHP Record page dwell time method, PHP page dwell time _php tutorial

Source: Internet
Author: User

PHP Record page dwell time method, PHP page dwell time


In this article, we describe the way PHP records the time spent on a page. Share to everyone for your reference, as follows:

First, in the page to be monitored add JS as follows

The log.php code is as follows

<?php$refer = '; if (isset ($_server[' http_referer ')) {  $refer = $_server[' Http_referer '];} $user _agent = ", if (isset ($_server[' http_user_agent ')) {  $user _agent = $_server[' http_user_agent '];} $ip = $_server[' remote_addr '];if (isset ($_get[' Stay_ms ')) {  $log = ' ['. Date ("Y-m-d h:i:s"). '] ' . $ip. ' ' . $refer. ' @ ' . Number_format ($_get[' Stay_ms '). "Ms\r\n";  File_put_contents ("Log/log_". Date ("y-m-d"). ". txt", $log, File_append);} if ($_server[' query_string ' = = "' | | isset ($_get[' Day ')) {  $day = isset ($_get[' Day '])? [$_get[' Day]: date (" y-m-d ") ;  $file = "Log/log_". $day. ". txt";  if (file_exists ($file))  {    $log = file_get_contents ($file);    echo nl2br ($log);  }}

More interested in PHP related content readers can view this site: "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", " PHP Date and Time usage summary, PHP Object-oriented Programming primer, PHP string usage Summary, PHP+MYSQL Database Operations Primer, and PHP Common database operations Tips Summary

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • PHP Setup page time-out resolution method
    • PHP Simple calculation of page load time method
    • PHP Implementation of timer page run time monitoring class
    • Introduction to the function of calculating PHP page run time
    • Implementation code to parse PHP calculation page Execution time
    • Get PHP page Execution time, database read and write times, number of function calls, etc. (thinkphp)
    • PHP one page execution time class code
    • PHP page Execution Time calculation code

http://www.bkjia.com/PHPjc/1117061.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117061.html techarticle PHP Record page dwell time method, PHP page dwell time This article describes the PHP record page dwell time method. Share to everyone for your reference, as follows: First of all, in order to ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.