建站学习(PHP+apache+mysql):2 将日志在页面展示
来源:互联网 发布:java中parse什么意思 编辑:程序博客网 时间:2024/05/20 16:41
一、读取文件并展示
<!DOCTYPE html>
<html>
<body>
<?php
$file = fopen("../Apache-20/logs/access.log","r");//打开文件;注意文件访问方式:php执行在htdocs目录下,跨目录的/apache-20/log对其可读
while(! feof($file))
{
echo fgets($file). "<br />"; //将日志取出一行并展示
}
fclose($file); //关闭文件
?>
</body>
</html>
二、读取文件并写入文件
<!DOCTYPE html>
<html>
<body>
<?php
//echo readfile("webdictionary.txt");
//$file = fopen("webdictionary.txt","r");
$file = fopen("../Apache-20/logs/access.log","r");
$myfile = fopen("../Apache-20/logs/mr_log", "w") or die("Unable to open file!");
while(! feof($file))
{
$tmp=fgets($file). "<br />";
fwrite($myfile, $tmp); // 注意文件访问方式:php执行在htdocs目录下,跨目录的/apache-20/log对其可写入
}
fclose($file);
fclose($myfile);
?>
</body>
</html>
0 0
- 建站学习(PHP+apache+mysql):2 将日志在页面展示
- 建站学习(PHP+apache+mysql):1.1 日志详解
- 建站学习(PHP+apache+mysql):1 创建环境并设置日志
- 建站学习(PHP+apache+mysql):3.日志中的字符串处理
- 建站学习(PHP+apache+mysql):4 css
- 在Mac 系统下搭建php学习环境(Apache+PHP+MySQL)
- LAMP(Linux+Apache+Mysql+PHP)部署日志
- FreeBSD+MySql+Postgresql+Apache+PHP安装日志
- apache+php+mysql 不能登录页面
- 新手学习PHP+MYSQL+Apache
- PHP学习之在Mac下配置php开发环境:Apache+php+MySql
- 在CentOS下搭建LAMP(Apache、MySQL、PHP)环境
- 在树莓派上搭建LAMP(Linux Apache Mysql PHP)服务器
- 在Redhat安装部署Apache+MySQL+PHP(LAMP)
- 在树莓派上搭建LAMP(Linux Apache Mysql PHP)服务器
- 在树莓派上搭建LAMP(Linux Apache Mysql PHP)服务器
- 将Apache的访问日志实时写入mysql数据库
- web 框架 Django 学习记录 (二)把数据库中表内容展示在页面
- Thread联系
- 在Mac OS X下安装toLua++
- C++ 中 Pair
- Qt界面布局和常用控件
- 在线盘口分析工具-秦俑量化盘口分析工具
- 建站学习(PHP+apache+mysql):2 将日志在页面展示
- 各协议(TCP/IP、UDP、HTTP、socket)内与外简述
- 【协议分析】DNS协议
- ubuntu mysql基本命令
- Latex中插入矢量图片(带latex公式)
- 《错不在我》 读后总结
- 两个队列实现一个桟
- 基于 AVOS Cloud 的 Android 应用程序快速开发简介
- read 命令详解