Share on Google+Share on Google+

PHP fwrite() Function & example

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

Advertisements

Posted on: October 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.