Write strings into a new file called "test.txt" in PHP

Description

The following code shows how to write strings into a new file called "test.txt".

Example


// w w w .  j a v  a  2 s  .  co  m
<?php
   $myfile = fopen("test.txt", "w") or die("Unable to open file!");
   $txt = "XML\n";
   fwrite($myfile, $txt);
   $txt = "XML\n";
   fwrite($myfile, $txt);
   fclose($myfile);
?>




















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip