Posted By

mischachen on 10/13/08


Tagged

textmate log php4 fileputcontents


Versions (?)

file_put_contents


 / Published in: PHP
 

  1. if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') ) {
  2. define('FILE_APPEND', 1);
  3. function file_put_contents($n, $d, $flag = false) {
  4. $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
  5. $f = @fopen($n, $mode);
  6. if ($f === false) {
  7. return 0;
  8. } else {
  9. if (is_array($d)) $d = implode($d);
  10. $bytes_written = fwrite($f, $d);
  11. fclose($f);
  12. return $bytes_written;
  13. }
  14. }
  15. }

Report this snippet  

You need to login to post a comment.