博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年5月12日

摘要: 1、写文件<?php //写文件 $file_path="text.txt"; if(!file_exists($file_path)){ echo "文件不存在"; exit(); } //"a+" 在文件后面追加 "w+"重新写入 $fp=fopen($file_path,"w+"); $con="\r\n你好"; for($i=0;$i<10;$i++){ fwrite($fp,$con);} echo "添加成功"; fclose($f 阅读全文

posted @ 2013-05-12 02:19 Step at a time 阅读(231) 评论(0) 推荐(0) 编辑

摘要: 1、读取文件操作<?php //读取文件 $file_path="text.txt"; if(!file_exists($file_path)){ echo "文件不存在"; exit(); } //打开文件 $fp=fopen($file_path,"a+"); //读取文件 $content=fread($fp,filesize($file_path)); echo "文件内容是:<br/>"; //默认情况下把内容输出到网页后,不会换行显示,因为网页不识别\r\n //所有要把\r\n .. 阅读全文

posted @ 2013-05-12 01:30 Step at a time 阅读(287) 评论(0) 推荐(0) 编辑