fwrite() function in PHP

PHPProgrammingServer Side Programming

The fwrite() function writes to an open file. It returns the number of bytes written on success, whereas returns False on failure.

Syntax

fwrite(file_pointer, string, length)

Parameters

  • file_pointer − A file system pointer created using fopen(). Required.

  • string − The string to be written. Required.

  • length − Maximum number of bytes to be written. Optional.

Return

The fwrite() function returns the number of bytes written on success, whereas returns False on failure.

Example

<?php
   $file_pointer = fopen("new.txt","w");
   echo fwrite($file_pointer,"This is test string!");
   fclose($file);
?>

Output

20
raja
Published on 03-Oct-2018 13:52:09
Advertisements