PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY (Free php web host) The
PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY The download file also contains code that displays the values of $readRest, $readAll, and $readAgain to show what happens at each stage of the read/write operations. The existing content in filetest05.txt was This works only the first time. When I typed Hello in fopen_pointer.php and clicked Write to file, I got the results shown to the left. Opening filetest05.txt revealed the results to the right. Compare the screenshots to see what happened. Table 7-3 describes the sequence of events. Table 7-3. Sequence of read/write operations in fopen_pointer.php Command Position of pointer Result $file = fopen($filename, ‘r+’); Beginning of file File opened for processing fwrite($file, $contents); End of write operation Form contents overwrites beginning of existing content while (!feof($file)) { $readRest .= fgets($file); } End of file Remainder of existing content read rewind($file); Beginning of file Pointer moved back to beginning of file $readAll = fread($file, filesize($filename)); See text Content read from beginning of file fwrite($file, $contents); At end of previous operation Form contents added at current position of pointer while (!feof($file)) { $readAgain .= fgets($file); } End of file Nothing read because pointer was already at end of file fclose($file); Not applicable File closed and all changes saved
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.