Current Location: Home> Function Categories> fwrite

fwrite

Write to files (safely used in binary files)
Name:fwrite
Category:File system
Programming Language:php
One-line Description:Write to the file.

Definition and usage

The fwrite() function writes to a file (safely used in binary files).

Example

 <?php
$file = fopen ( "test.txt" , "w" ) ;
echo fwrite ( $file , "Hello World. Testing!" ) ;
fclose ( $file ) ;
?>

Output:

 twenty one

grammar

 fwrite ( file , string , length )
parameter describe
file Required. Specifies the open file to be written.
string Required. Specifies the string to be written to the file.
length Optional. Specifies the maximum number of bytes to be written.

illustrate

fwrite() writes the contents of string to the file pointer file . If length is specified, the writing will stop when length bytes are written or string is finished, depending on which situation is encountered first.

fwrite() returns the number of characters written, and returns false when an error occurs.

Similar Functions
  • Returns the total size of the file system or disk partition disk_total_space

    disk_total_space

    Returnsthetotalsizeo
  • alias for fwrite fputs

    fputs

    aliasforfwrite
  • Get the last access time of the file fileatime

    fileatime

    Getthelastaccesstime
  • Change the group to which the file belongs chgrp

    chgrp

    Changethegrouptowhic
  • Open process file pointer popen

    popen

    Openprocessfilepoint
  • Return the target of the symbolic link readlink

    readlink

    Returnthetargetofthe
  • Modify the owner of the symbolic link lchown

    lchown

    Modifytheownerofthes
  • Read the entire file into an array file

    file

    Readtheentirefileint
Popular Articles