-----024-file.php-----
1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">5<title> File Handling </title>67<body>89<pre>Ten<?PHP One $f _zzz=Iconv(' Utf-8 ', ' gbk ', ' D:\a\res\txt\ compound surname Utf-8.txt '); A $fp _zzz=fopen($f _zzz, ' R ');//open file, return file handle - $arr _zzz=file($f _zzz);//file = array - $str _zzz=file_get_contents($f _zzz);//File = = String the $arr _temp=Explode(‘ ‘,Preg_replace(' #\s+# ', ',$str _zzz)); - Var_dump($arr _temp); - Echo fread($fp _zzz, +), "\ n";//read 100 bytes of a file - Echo fgetc($fp _zzz), "\ n";//read one character + Echo fgets($fp _zzz), "\ n";//read a row - Echo FGETSS($fp _zzz), "\ n";//read a row, filter HTML PHP tags + Var_dump(Fgetcsv($fp _zzz));Echo"\ n";//read a row, filter HTML PHP tags A Echo Fpassthru($fp _zzz);Echo"\ n";//read the remaining files at Echo ReadFile($f _zzz);//Read all Files - fclose($fp _zzz); -?> -</pre> -</body> -
-----025-file_write.php-----
1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">5<title> Write Files </title>67<body>89<pre>Ten<?PHP One $f _zzz=Iconv(' Utf-8 ', ' gbk ', ' D:\a\res\txt\php write file test. txt '); A $fp _zzz=fopen($f _zzz, ' W '); - file_put_contents($f _zzz, "to the poor Trinidad and the eyes \ n");//Write a string - fwrite($fp _zzz, "The day depends on the mountain."); the fwrite($fp _zzz, "Yellow River into the current \ n"); - fputs($fp _zzz, "A higher level \ n"); - Echo"Current file pointer position:",Ftell($fp _zzz), "\ n"; - fseek($fp _zzz, 32);//move the file pointer to the beginning of the third line + fwrite($fp _zzz, "to the Poor thousand"); - fseek($fp _zzz,-9, seek_cur);//pointer moves forward one line + fwrite($fp _zzz, "Long sighing to hide."); A Rewind($fp _zzz); at fwrite($fp _zzz, "The window contains the West ridge Snow"); - - - - - in fclose($fp _zzz); - Echo"File content: \ n".file_get_contents($f _zzz); to?> +</pre> -</body> the