Write formated to a text file named "test.txt" in PHP

Description

The following code shows how to write formated to a text file named "test.txt".

Example


  /*from   ww  w.  jav a 2s .  co m*/
<?php
   $number = 20;
   $str = "Beijing";
   $file = fopen("test.txt","w");
   echo fprintf($file,"There are %u million people in %s.",$number,$str);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




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