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
  • Get the inode of the file fileinode

    fileinode

    Gettheinodeofthefile
  • Return to the directory part in the path dirname

    dirname

    Returntothedirectory
  • Delete directory rmdir

    rmdir

    Deletedirectory
  • Move uploaded files to a new location move_uploaded_file

    move_uploaded_file

    Moveuploadedfilestoa
  • See unlink() or unset() (PHP does not have delete keywords or functions) delete

    delete

    Seeunlink()orunset()
  • Read characters from file pointer fgetc

    fgetc

    Readcharactersfromfi
  • Change the current umask umask

    umask

    Changethecurrentumas
  • Open process file pointer popen

    popen

    Openprocessfilepoint
Popular Articles