⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 08c07-1.php

📁 介绍PHP5的给类型函数应用
💻 PHP
字号:
<?php// Don't allow this page to be cached, since it should always be fresh.header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Tail of logfile</title></head><body><pre><?php// Open the file we wish to read - In this case the access log of our serverif (!($fp = fopen("/var/log/apache2/access.log", 'r'))) {    // We couldn't open the file, error!    echo "ERROR: Could not open file for reading!\n";    exit();}// We don't want to display the entire file, it could be huge, so //  let's use a quick way to just display some of the file.  Use fseek//  to head to the end of the file, but back up by 500 bytes.fseek($fp, -500, SEEK_END);// Read one line of data to throw away, as it may be an incomplete//  line due to our seek.fgets($fp);// Keep looping foreverfor (;;) {    // We can begin to loop through reading all lines and echoing them:    while (!feof($fp)) {        if ($line = fgets($fp)) { echo $line; }    }    // Ok, we hit the end of the file, there are a few odd-n-ends we need:    // First reseek to the end of the file, this is necessary to reset    //  the filepointer, else it won't read anything else.    fseek($fp, 0, SEEK_END);    // Secondly flush the output buffers so that all text appears:    flush();    // Also reset the time limit for PHP so that we never time out:    set_time_limit(15);    // Now sleep for 1 second, and then we will try to access it again.    sleep(1);}?></pre></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -