readfile() function in PHP


The readfile() function read a file and writes it to the output buffer.

Syntax

readfile(file_path, include_path, context)

Parameters

  • file_path − The path of the file

  • include_path − Set this parameter to TRUE, if you want to search for the file in the include_path

  • context − Specifies the behavior of the stream.

Return

The readfile() function returns the number of bytes read from the file.

Example

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

The following is the output that returns the number of bytes.

Output

This is demo text!
18

Updated on: 24-Jun-2020

143 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements