Page 305 - CITS - CSA - TP (Volume 1) - Hindi
P. 305

कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS
















           टा  7: कं ट ट जोड़ने के  िलए फ़ाइल ओपन करना
           1  टे  एिडटर ओपन कर

           2  िन िल खत कोड िलख

                              <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   ो ाम को C:\Apache24\htdocs म  .php ए ट शन वाले फ़ो र म  सेव कर
           4  िवंडोज़ सिव स से Apache सिव स रन कर

           5   ाउज़र ओपन कर  और िन  एड ेस टाइप कर
              http://localhost/foldername/

           6  रन करने के  िलए php फ़ाइल पर   क कर  और आउटपुट वेरीफाई कर



                                                           289

                                     CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 55
   300   301   302   303   304   305   306   307   308   309   310