Current Location: Home> Function Categories> readfile

readfile

Output file
Name:readfile
Category:File system
Programming Language:php
One-line Description:Read a file and output it to the output buffer.

Definition and usage

readfile() function outputs a file.

This function reads into a file and writes to the output buffer.

If successful, return the number of bytes read from the file. If it fails, return false. You can call the function in the form of @readfile() to hide the error message.

实例

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

输出:

There are two lines in this file.
This is the last line.
57

grammar

 readfile ( filename , include_path , context )
parameter describe
filename Required. Specifies the file to be read.
include_path Optional. If you also want to search for files in include_path , you can use this parameter and set it to true.
context Optional. Specifies the environment for file handles. Context is a set of options that can modify the behavior of a stream.

illustrate

Support for context parameters is added by PHP 5.0.0.

Similar Functions
  • Get the inode modification time of the file filectime

    filectime

    Gettheinodemodificat
  • Modify all groups of symbolic links lchgrp

    lchgrp

    Modifyallgroupsofsym
  • Set file access and modification time touch

    touch

    Setfileaccessandmodi
  • Close an open file pointer fclose

    fclose

    Closeanopenfilepoint
  • Parse a configuration file parse_ini_file

    parse_ini_file

    Parseaconfigurationf
  • Read files (safely used in binary files) fread

    fread

    Readfiles(safelyused
  • Open process file pointer popen

    popen

    Openprocessfilepoint
  • Write to files (safely used in binary files) fwrite

    fwrite

    Writetofiles(safelyu
Popular Articles