Home

See the related posts

Mysql server version using php function – mysql_get_server_info()    Text file prompt download or force download using php    Number of lines in a file using php    Check Image exists or Not Using php and GD    PHP Warning: Call-time pass-by-reference has been deprecated   

PHP File write function

File Write

fwrite function is used to write contents to a file. fwrite needs file pointer and contents of type string as parameters. fwrite returns number of bytes written on
success , or FALSE on error.
Example :

<?php
    $content =  'This content is to test';
    if ( is_writable ('example.txt') ){
    $fp = fopen ('example.txt', 'w');
    if (  !$fp ){
    echo 'error : coud not open file  example.txt  ';
    }else{
    if (! ( $length  =  fwrite($fp, $content )  )   ){
    echo 'writing to the file failed';
    }else{
    echo 'Content wrote  successfully to the file';
    }
   fclose($fp);
   }
   }
  ?> 

Home

See the related posts

Mysql server version using php function – mysql_get_server_info()    Text file prompt download or force download using php    Number of lines in a file using php    Check Image exists or Not Using php and GD    PHP Warning: Call-time pass-by-reference has been deprecated   

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment