Use PHP readfile function to open any file on screen using Echo

How to open and show XML, AJAX, CSS,HTML,SVG,SQL,PHP files directly on screen using php readfile() method.

Php gives us readfile() method to open any type of development file supported to web browser. For example if we want to open php files then we just have to pass our php file name inside readfile() method and it will calls it exactly. So in this tutorial we are opening a simple text file using this function. So here is the complete step by step tutorial for How to Use PHP readfile function to open any file on screen using Echo.

android-project-download-code-button

How to Use PHP readfile function to open any file on screen using Echo.

Code for readfile.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>How to Use PHP readfile function</title>
</head>

<body>

<?php

echo readfile("demo.txt")

?>
</body>
</html>

Code for demo.txt file.

 THIS TEXT COMES FROM DEMO.TXT FILE.

Screenshot:

Use PHP readfile function to open any file on screen using Echo

Click here to download Use PHP readfile function to open any file on screen using Echo project file with source code.