Home Tutorial Php Phpfiles PHP fwrite() Function & example

 
 

Share on Google+Share on Google+
PHP fwrite() Function & example
Posted on: October 30, 2009 at 12:00 AM
Advertisement
This segment of the PHP tutorial illustrates the use of file handling function fwrite() and its example

Syntax

int fwrite ( file_handle ,data_string [,length ] )

  • fwrite() function writes to the file with the given data string by using the file handle
  • It writes up to the given length argument.
  • It returns the no of bytes written to the file.
  • It returns FALSE if the file doesn't exist or if the file is opened in read form


Example of PHP fwrite() Function

Code
<?php

    $file
=fopen("aa.txt","a+");
    echo
file_get_contents("aa.txt");
    fwrite($file,"\n so have a behavour of the human being ");
    echo
"<br>".file_get_contents("aa.txt");
?>

Output
we all are human
we all are human so have a behaviour of the human being

Advertisement

Related Tags for PHP fwrite() Function & example:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 30, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com