0% found this document useful (0 votes)
9 views3 pages

Web Tech 20 Feb

The document consists of four PHP scripts demonstrating file operations: creating a file and writing to it, reading from an existing file, appending additional content to the file, and checking for file existence. Each script includes user feedback messages indicating success or failure of the operations. The scripts all reference the same file, 'example.txt', and include the author's name, Mohammed Akib FYCS67.

Uploaded by

kccollege0123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Web Tech 20 Feb

The document consists of four PHP scripts demonstrating file operations: creating a file and writing to it, reading from an existing file, appending additional content to the file, and checking for file existence. Each script includes user feedback messages indicating success or failure of the operations. The scripts all reference the same file, 'example.txt', and include the author's name, Mohammed Akib FYCS67.

Uploaded by

kccollege0123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

<?php

$file=fopen("example.txt","w");

fwrite($file,"Hello, This is web tech 2!");

fclose($file);

echo"Mohammed Akib FYCS67<br>";

echo"Data written to file successfully.";

?>

2.

<?php

$filename="example.txt";

if(file_exists($filename))

$file=fopen($filename,"r");

$content=fread($file,filesize($filename));

fclose($file);

echo"Mohammed Akib FYCS67<br>";

echo "File content:".$content;

else

echo"File does not exist.";

?>
3.Appending

<?php

$filename="example.txt";

if(file_exists($filename)){

$file=fopen($filename,"a");

fwrite($file,"\nThis is an appended line.");

fclose($file);

echo"Mohammed Akib FYCS67<br>";

echo"Data appended to file successfully.";

else{

echo"File does not exist.";

?>

4.Delete.

<?php

$filename="example.txt";

if(file_exists($filename)){

$file=fopen($filename,"a");
fwrite($file,"\nThis is an appended line.");

fclose($file);

echo"Mohammed Akib FYCS67<br>";

echo"Data appended to file successfully.";

else{

echo"File does not exist.";

?>

You might also like