Trying to create a dynamic filename with PHP on a localhost.
<?php
// Create a file with the submitted story
$created_at = date("Y-m-d-H:i:s");
$filename = "c:\\Users\\Kirk\\Dropbox\\school\\CS 491\\files\\$created_at.txt";
echo $filename;
$handle = fopen($filename, 'w+');
fclose($handle);
?>
I am able to create a new file, but I get $create_at.txt
instead of something like: 2015-04-20-21:00:00.txt
.
I've tried numerous escape changes. For instance, if I put $filename
inside of quotes like this: fopen("$filename", "w+");
I get a file in my main directory called $filename
.