PHP Examples - Files


PHP Examples - Files

Program:

<html >
<head>

<title>PHP Example 12 : FILES</title>
</head>

<body>

<?php
 
 echo "PHP Example 12";
 echo"<br/>"; // line break
 echo"<h1>";
 echo"FILES";
 echo"</h1>";
 echo"<br/>";

 $filename="testfile.txt"; // Filename 
 
 $f1=fopen("$filename","w"); // Opening file in write mode
 echo "<br/>testfile.txt created.<br/>";
 fwrite($f1,"www.2k8618.blogspot.com"); // Writing data to file
 echo "<br/>Data written.<br/>";

 fclose($f1); //File closed
// echo "<br/>File closed.<br/>";


 $f2=fopen("$filename","r"); // Opening file in read mode

 $dataop= fread($f2,25); // Data read from file
 
 echo "<br/>Data read.<br/>";
 echo $dataop;
 fclose($f2);
  
 // unlink($filename); // to delete file
 

 echo"<br/>";

 echo "<br/><b>";
 echo"WWW.2K8618.BLOGSPOT.COM";
 echo"</b>";
?>


</body>
</html>

Output:



2 comments:

  1. Interesting example. Would be great if you can add it to our website http://www.programr.com. We have onsite simulator and love programmers like you to share the word of our website.

    ReplyDelete
  2. Innomatics Research Labs is collaborated with JAIN (Deemed-to-be University) and offering the Online MBA in Artificial Intelligence & Business Intelligence Program. It is a sublime program of getting an MBA degree from one of the best renowned university – JAIN University and an IBM certification program in Data Science, Artificial Intelligence, and Business Intelligence from Innomatics Research Labs in collaboration with Royal Society London.

    Online MBA in Artificial intelligence from Jain University

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...