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);
}
}
?>




