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
  • Positioning in file pointer fseek

    fseek

    Positioninginfilepoi
  • Set file access and modification time touch

    touch

    Setfileaccessandmodi
  • All remaining data at the output file pointer fpassthru

    fpassthru

    Allremainingdataatth
  • Rewind the file pointer position rewind

    rewind

    Rewindthefilepointer
  • Read a line from a file pointer fgets

    fgets

    Readalinefromafilepo
  • Determine whether the given file name is a symbolic connection is_link

    is_link

    Determinewhethertheg
  • Test whether the file pointer reaches the end of the file feof

    feof

    Testwhetherthefilepo
  • Returns the file path information pathinfo

    pathinfo

    Returnsthefilepathin
Popular Articles