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:



4 comments:

  1. Great post indeed and thanks for all the information, it was very helpful i really like that you are providing information on PHP and MYSQL with basic JAVASCRIPT,being enrolled in http://www.wiziq.com/course/5871-php-mysql-with-basic-javascript-integrated-course i was looking for such information online to assist me on php and mysql and your information helped me a lot. Thanks.

    ReplyDelete
  2. 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
  3. This is an amazing blog,it gives very helpful messages to us.Besides that Wisen has established as Best Javascript Training in Chennai . or learn thru JavaScript Online Training India. Nowadays JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...