Advertisement
Bruno

[PHP] Criar And escrever em um arquivo

May 15th, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. /* Função de criar e escrever no arquivo, criado por Bruno Pereira
  2.     www.projetosbrunopereira.com.br
  3.  
  4. Ex:
  5. file_CreateAndWrite("Testando.txt", "www.projetosbrunopereira.com.br");
  6. */
  7.  
  8. function file_CreateAndWrite($file, $text) {
  9.         if(empty($text)) {
  10.             file_exists($file) ?: $file = fopen($file, "a");
  11.         }
  12.         else {
  13.             file_exists($file) ?: $file = fopen($file, "a+");
  14.             fwrite($file, $text);
  15.             fclose($file);
  16.         }
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement