PHP Tutorial

Please follow & like us :)

How to create file in php: 

In many application, you need to create data dump or copy the data from third party every day. You can use this code to create the file and write data to the file.

Here, we have given fixed name to the file but you can create name programmatically to mention date as well.

<?php

  $file_name = 'product.txt';
  $file_path = '/products/audio';
  $dest = $file_path. '/' .$file_name;
  $file_handler = fopen($dest, 'w') or die("can't open file");
  fclose($file_handler);

?>