Current Location: Home> Function Categories> fgetc

fgetc

Read characters from file pointer
Name:fgetc
Category:File system
Programming Language:php
One-line Description:Return characters from the opened file.

Definition and usage

The fgetc() function reads a character from the file pointer.

Example

Example 1

 <?php

$file = fopen ( "test.txt" , "r" ) ;
echo fgetc ( $file ) ;
fclose ( $file ) ;

?>

The output is similar:

 H

Example 2

 <?php

$file = fopen ( "test.txt" , "r" ) ;

While ( ! feof ( $file ) )
  {
  echo fgetc ( $file ) ;
  }

fclose ( $file ) ;
?>

The output is similar:

 Hello, this is a test file.

grammar

 fgetc ( file )
parameter describe
file Required. Specify documents to be inspected.

illustrate

Returns a string containing a character obtained from the file pointed to by the file. If EOF is encountered, it returns false.

The file pointer must be valid and must point to a file that was successfully opened by fopen() or fsockopen() (but has not been closed fclose() ).

Similar Functions
  • Delete directory rmdir

    rmdir

    Deletedirectory
  • Get the file owner fileowner

    fileowner

    Getthefileowner
  • Returns the file name part in the path basename

    basename

    Returnsthefilenamepa
  • Returns the file path information pathinfo

    pathinfo

    Returnsthefilepathin
  • Match file names with pattern fnmatch

    fnmatch

    Matchfilenameswithpa
  • Lightweight consultation file locking flock

    flock

    Lightweightconsultat
  • Get the inode of the file fileinode

    fileinode

    Gettheinodeofthefile
  • Open a file or URL fopen

    fopen

    OpenafileorURL
Popular Articles