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 ...