This is a basic PHP program based on file handling which explains how to close a file in PHP with an example. This example will help you to more understanding of file handling in PHP programming language.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <html> <head> <title>Closing a file in PHP</title> </head> <body> <?php echo "<p>Opening the file <b>codescracker.txt</b> .....</p>"; $myfile = fopen("codescracker.txt", "r"); if($myfile == false) { echo "Error occurred...exiting..."; exit(); } echo "<p>File opened successfully.</p>"; echo "<p>Closing the file....</p>"; fclose($myfile); echo "<p>File closed successfully.</p>" ?> </body> </html> |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.