MrDoug Posted July 5, 2008 Share Posted July 5, 2008 I have an html file that takes user input and sends it to a php file which looks somthig like this... <?php $name = $_POST['name']; $input = $_POST['input']; $fp = fopen('$name' . '.html', 'a'); fwrite($fp, '$input'); fclose($fp); ?> so basicly i want it to open the html file that the user wants, and there write the user input to it. however, instead it just creates a new html file called "$name.html". My question how do I make it read "$name" as a php variable instead of just a file name? can it be done? is there a better way? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/113298-variables-in-fopen-filename/ Share on other sites More sharing options...
ron8000 Posted July 5, 2008 Share Posted July 5, 2008 Have you tried to take it out of quotes? or try -> $fp = fopen($name . '.html', 'a'); Link to comment https://forums.phpfreaks.com/topic/113298-variables-in-fopen-filename/#findComment-582120 Share on other sites More sharing options...
bluejay002 Posted July 5, 2008 Share Posted July 5, 2008 you do not need to put quotes intentionally to variables unless it has other literal characters together with it. <?php $name = $_POST['name']; $input = $_POST['input']; $fp = fopen($name . '.html', 'a'); fwrite($fp, $input); fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/113298-variables-in-fopen-filename/#findComment-582152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.