Create a New File in PHP

Create a New File in PHP:

<?php
$filename = “e:/ashu.txt”;
if(file_exists($filename))
{
$msg = “file already exists”;
}
else
{
$newfile = fopen($filename, “w+”)  or die(“Unable to create file”);
fclose($newfile);
$msg = “<p>file created</p>”;
}
?>
<html>
<head>
<title>
Creating a new file
</title>
</head>
<body>
<? echo $msg; ?>
</body>
</html>

About the author

Being the CEO and Founder of ClecoTech International, Mr. Ashish Prajapati is dedicated towards his aim of mentoring young startups into a full-fledged businesses. He is helping startups from America, Europe, India, and various other countries through proper guidance and the use of latest technologies to develop their innovation and ideas into definite realities.

Leave a Reply

Your email address will not be published. Required fields are marked *