j115 Posted October 10, 2008 Share Posted October 10, 2008 I need a PHP Script that makes a PHP file in a directory. I want the name of the php file to be the named by the contents of a text-box. I made a from and made it go to create.php Now on create.php I need to figure out how to make a php file and I need it to be called whatever the contents of the text-box name. Is this possible? If so, all help would be appreciated! Link to comment https://forums.phpfreaks.com/topic/127787-php-create-file/ Share on other sites More sharing options...
trq Posted October 10, 2008 Share Posted October 10, 2008 Take a look at fopen() & fwrite(). Link to comment https://forums.phpfreaks.com/topic/127787-php-create-file/#findComment-661472 Share on other sites More sharing options...
j115 Posted October 10, 2008 Author Share Posted October 10, 2008 Take a look at fopen() & fwrite(). How do I actually create the file. That seemed to write to a file. But, I also need it to be writing a PHP File not a TXT File. Link to comment https://forums.phpfreaks.com/topic/127787-php-create-file/#findComment-661476 Share on other sites More sharing options...
Archadian Posted October 10, 2008 Share Posted October 10, 2008 fwrite() will create the file if it does not exist in that directory and it will input the contents in that file for you. Link to comment https://forums.phpfreaks.com/topic/127787-php-create-file/#findComment-661554 Share on other sites More sharing options...
tibberous Posted October 10, 2008 Share Posted October 10, 2008 `touch test.txt` Only works on Lindows, and other Lindows variants. Link to comment https://forums.phpfreaks.com/topic/127787-php-create-file/#findComment-661583 Share on other sites More sharing options...
taith Posted October 10, 2008 Share Posted October 10, 2008 ? just write in the content into the data segment... it can handle any code... as long as it can be read when you save the file... you should be fine file_put_contents('yourphpfile.php','<?echo 'hello world';?>'); Link to comment https://forums.phpfreaks.com/topic/127787-php-create-file/#findComment-661589 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.