YourNameHere Posted February 3, 2010 Share Posted February 3, 2010 Is it possible to create a .php file using PHP commands? this is from tizag.com [pre]$myFile = "testFile.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "New Stuff 1\n"; fwrite($fh, $stringData); $stringData = "New Stuff 2\n"; fwrite($fh, $stringData); fclose($fh); [/pre] That creates a .txt file, it is possible to do, sometext.php? and echo or print variables in it? Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/ Share on other sites More sharing options...
trq Posted February 3, 2010 Share Posted February 3, 2010 That creates a .txt file, it is possible to do, sometext.php? and echo or print variables in it? Of course it is. Everyone Ive seen do this however has done so because of a poor design choice. Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1005926 Share on other sites More sharing options...
YourNameHere Posted February 3, 2010 Author Share Posted February 3, 2010 the reason I want to do it is I am making a administrative back-end to a site and would like to allow the admin to add pages to the site with a common layout template. This is just my initial idea. If you have a better way, please enlighten me. Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1005933 Share on other sites More sharing options...
Mchl Posted February 3, 2010 Share Posted February 3, 2010 the reason I want to do it is I am making a administrative back-end to a site and would like to allow the admin to add pages to the site with a common layout template. This is just my initial idea. If you have a better way, please enlighten me. Perhaps you should instead have a common template that could be filled with content from database? Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1005937 Share on other sites More sharing options...
YourNameHere Posted February 3, 2010 Author Share Posted February 3, 2010 Perhaps you should instead have a common template that could be filled with content from database? That is in fact what I will be doing. However, how would that content have a unique URL other than get vars? I'd rather make a function that creates a new script altogether. But if that is a poor design choice... I guess I am probably misunderstanding what you mean. Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1006216 Share on other sites More sharing options...
Mchl Posted February 3, 2010 Share Posted February 3, 2010 However, how would that content have a unique URL other than get vars? Google mod_rewrite Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1006225 Share on other sites More sharing options...
YourNameHere Posted February 3, 2010 Author Share Posted February 3, 2010 I know mod_rewrite. So your saying I should rewite it to appear as though it is a separate page? Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1006295 Share on other sites More sharing options...
Mchl Posted February 3, 2010 Share Posted February 3, 2010 That's how most people do it. Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1006329 Share on other sites More sharing options...
YourNameHere Posted February 3, 2010 Author Share Posted February 3, 2010 Ok, thank for your advice. Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1006339 Share on other sites More sharing options...
trq Posted February 3, 2010 Share Posted February 3, 2010 Do you really think this forum software creates a new file every time someone makes a new thread? Your kinda missing the whole point of a dynamic web site. Link to comment https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/#findComment-1006393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.