How to use File Open or Read in PHP

In this article, you will learn How to use File Open or Read in PHP.

A method to open file in PHP fopen() function. This function provides you many options than the readfile() function. We can use the type of file with this function.

  • AJAX = Asynchronous JavaScript and XML
  • CSS = Cascading Style Sheets
  • HTML = Hyper Text Markup Language
  • PHP = PHP Hypertext Preprocessor
  • SQL = Structured Query Language
  • SVG = Scalable Vector Graphics
  • XML = EXtensible Markup Language

Example:-

index.php

<?php
$myfile = fopen("file.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("webdictionary.txt"));
fclose($myfile);
?>

file.txt

Welcome to Hub of Tutorials

Leave a Comment