Page 304 - CITS - CSA - TP (Volume 1) - Hindi
P. 304
कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS
टा 6: टे कं ट ट िलखने के िलए फ़ाइल ओपन करना
1 टे एिडटर ओपन कर
2 िन कोड िलख
<html>
<body>
<?php
// Specify the file name
$fileName = ‘example.txt ;
// Open the file in write mode (‘w )
$fileHandle = fopen($fileName, ‘w );
// Check if the file is opened successfully
if ($fileHandle)
{
// Write content to the file
fwrite($fileHandle, ‘This is a line of text. );
// Close the file handle
fclose($fileHandle);
echo “File ‘$fileName has been written successfully.”;
}
else
{
// Display an error message if the file cannot be opened
echo “Error: Unable to open the file for writing.”;
}
?>
</body>
</html>
3 ो ाम को C:\Apache24\htdocs म .php ए ट शन वाले फ़ो र म सेव कर
4 िवंडोज़ सिव स से Apache सिव स रन कर
5 ाउज़र ओपन कर और िन एड ेस टाइप कर
http://localhost/foldername/
6 रन करने के िलए php फ़ाइल पर क कर और आउटपुट वेरीफाई कर
288
CITS : IT & ITES - कं ूटर सॉ वेयर ए ीके शन - अ ास 55

