/**
- 打开文件fopen
- 读写文件 fgets,fwrite
- 关闭文件fclose
- 1附加函数feof是否已经到末尾
- 2一次将所有文件读出file_get_contents($filename)
- 3使用file_put_content($filename)
*/
//按行读取`
// $fp=fopen("D:/VM12/hello.txt","r");
// while(!feof($fp)){
// $line=fgets($fp);
// $line=str_replace("\n","<br/>",$line);
// echo $line;
// }
// fclose($fp);
//写入
// $fp=fopen("D:/VM12/hello.txt","a");
// fwrite($fp,"\n2222");
// fclose($fp);
// header("content-type:text/html;charset='gbk'");
// $content=file_get_contents("D:/VM12/hello.txt");
// $content=iconv("GBK","UTF-8",$content);
// $list=explode("\n",$content);
// print_r($list);
//使用file_get_contents可以访问网页;
// $content=file_get_contents("http://www.woniunote.com");
// echo $content;
//网页爬虫的设计思路
/**
- 编码转义,utf三字节处理,gbk两字节处理
*/
/ $content=iconv("UTF-8","GBK","\n勒布朗詹姆斯");
// file_put_contents("D:/VM12/hello.txt",$content,FILE_APPEND);
//读取csv文件逗号分隔符文件并且解析为二维数组
// $content=file_get_contents("D:/VM12/hello.txt");
// $rows=explode("\n",$content);
// $list=array();
// for($i=1;$i<count($rows);$i++){
// $temp=explode(",",$row[1]);
// array_push($list,$temp);
// }
// print_r($list);
//使用php模拟tail-f实时查看文件内容
//获取当前文件指针位置ftell
//直接将文件指针指向某一个位置
/ $fp=fopen("filename");
// fseek($fp,25);
// while($line=fgets($fp)){
// echo $line ."<br/>";
// }
// fclose($fp);
// set_time_limit(0);
// $pos=0;
// while(true){
// $fp=fopen("test.txt","r");
// fseek($fp,$pos);
// while($line=fgets($fp)){
// $line=iconv("GBK","utf-8",$line);
// echo $line ."<br/>";
// }
// $pos=ftell($fp);
// fclose($fp);
// ob_flush();
// flush();
// sleep(2);
// }