JavaScript Tutorial

File Handling – PHP Advanced

File Handling is the most important part of web application. For different task you need to open and process a file.

Manipulating Files :

Creating, Reading, Uploading, and Editing files has several functions for PHP.
If you do something wrong, it can damage a lot so be careful while manipulating files. Filling a hard-drive with garbage data, editing wrong files and by mistake deleting a content of a file : these are the common errors.

readfile() funtion

This function reads & writes it to output buffer. If you want to open file and read its all contents then readfile() is much useful.

  • At first, i have created a file named “example.txt” which contains the following information :-

This is an example.
#teamcodeprojects – projects, tutorial and more

NOW PHP CODE READs THE FILE AND DISPLAYS THE OUTPUT :

<!DOCTYPE html>
 <html>
 <body>

<?php
 echo readfile("example.txt");
 ?>

</body>
 </html>

Output :

0 0 vote
Article Rating
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Mohit Gupta
1 year ago

Could not connect database .

this is the error

2
0
Would love your thoughts, please comment.x
()
x