• Have Any Question?
  • contact@eitworld.com

PHP File Read

  • We have to use the function “fopen” to open the file for reading.

$myFile = "read.txt";
$myfilehandle = fopen($myFile, 'r');

fread Function

    • Your PHP script that you are writing should reside in the same directory as “write.txt”. Here are the contents of our file from File Write.

Mohan Verma
Shyam Dua
    • Now that the file is open, with read permissions enabled, we can get started!
    • The fread function is the staple for getting data out of a file. The function requires a file handle, which we have, and an integer to tell the function how much data, in bytes, it is supposed to read.
    • One character is equal to one byte. If you wanted to read the first 3 characters then you would use 3 as the integer.

$myFile = "write.txt";

$$myfilehandle = fopen($myFile, 'r');

$theData = fread($myfilehandle, 3);


echo $theData;

    • It will produce following output:.

  • The first five characters from the write.txt file are now stored inside $theData. You could echo this string, $theData, or write it to another file.
  • Powerful and Efficient.

application of c language

C language is used to develop a simple program and as well as complex Application and System software also. Some of the applications of C language are given below:

  • Databases
  • Operating system
  • Utilities
  • Modern Programs
  • Simulators
  • Compiler, Assembler and Interpreter
  • Network Drivers
  • Text Editors and Print Spoolers.

Overview of Compiler and Interpreters

Before talking about the Compiler and Interpreter we have to know some important points as given below:

  • A program is a set of instructions used to perform a particular task.
  • These programs are written in assembly language or high level language (English words),this written program is called as source program which cannot be understood by the computer. Computer can only understand the instructions available in the form of machine language as ‘0’ and ‘1’.
  • The source program is to be converted to the machine language that is known as object program.
  • Source program is converted into object program with the help of interpreter or compiler which are explained here in detail:


  • Compiler reads the entire source program and converts it into the object program.
  • Compiler provides errors of entire program at once instead of providing them line by line. Only error free program can be executed.
  • Compiler consumes less time for converting source program to object program.
  • Compiler is preferred where length of the source program is very large.


  • Interpreter reads only one line of source program at a time and converts it into the object code.
  • Interpreter provides error line by line.
  • Interpreter consumes more time for converting source program to object program than compiler.

Real Time Web Analytics