faqts : Computers : Programming : Languages : PHP : Common Problems : Files

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 23 people (74%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How do I get php to create the new file $variable.inc ?

Mar 23rd, 2001 13:18
Ben Udall, mike gifford, http://www.php.net/manual/en/function.fopen.php


$filename = 'newfile.inc';
$contents = "<? echo 'This is a new file.'; ?>";
if ($fp = fopen($filename, 'w'))
{
   fwrite($fp, $contents);
   fclose($fp);
}