Page 293 - Computer Software Application TP - Volume 1
        P. 293
     COMPUTER SOFTWARE APPLICATION - CITS
              2  Write the following codes
                              <html>
                              <body>
                            <?php
                                              //  Specify the file name
                         $fileName = ‘example.txt’;
                         // Open the file in append mode (‘a’), create the file if it doesn’t   exist
                         $fileHandle = fopen($fileName, ‘a’);
                         // Check if the file is opened successfully
                         if ($fileHandle)
                         {
                                 // Append content to the file
                                 fwrite($fileHandle, ‘This is a line of text appended to the file.’);
                                 // Close the file handle
                                 fclose($fileHandle);
                                 echo “File ‘$fileName’ has been appended successfully.”;
                         }
                         else
                         {
                                 echo “Error: Unable to open or create the file for appending.”;
                         }
              ?>
                     </body>
                             </html>
           3  Save the program in C:\Apache24\htdocs in a folder with .php extension
           4  Run the Apache services from windows services
           5  Open the browser and type the following address
                                  http://localhost/foldername/
           6  Click the php file to run  and verify the output
           TASK 8: Writing Data to the file
           1  Open the text editor
           2  Write the following codes
                           <html>
                           <body>
                                                           278
                                CITS : IT & ITES - Computer Software Application - Exercise 55
     	
