PHP5 getting started to read and write text files (2 )?? ====================== Write a file =======================$ realFiePath = "D: /test.txt "; $ fileContent =" Test20110312 .";? $ File = fopen ($ realFiePa PHP 5 getting started to read and write text files (2)
??
====================
Write files
====================
$ RealFiePath = "D:/test.txt ";
$ FileContent = "Test 2011 03 12 .";
?
$ File = fopen ($ realFiePath, 'WB ');
Fwrite ($ file, $ fileContent );
Fclose ($ file );
?
?
====================
Read files
====================
$ RealFiePath = "D:/test.txt ";
$ Size = intval (sprintf ("% u", filesize ($ realFiePath )));
$ Handle = fopen ($ realFiePath, "rb ");
$ FileContent = "";
?? While (! Feof ($ handle )){
????? $ FileContent. = fread ($ handle, $ size );
????? Ob_flush ();
??? ?? Flush ();
??}
?? Fclose ($ handle );
?
Echo $ fileContent;