papaface Posted May 30, 2007 Share Posted May 30, 2007 Hello, How would I go about creating a new php file with php tags in it? I am creating a config file on the fly. So it would need to be like: <?php $username = "lalala"; $site = "site site"; ?> Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/53574-create-a-new-php-file/ Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 We need more information. Do you want to create that file from a php script, you do you just want to create it in an editor? If you want to create it from a php script look into: www.php.net/fopen www.php.net/fwrite www.php.net/fclose All of those will get you on your way. Link to comment https://forums.phpfreaks.com/topic/53574-create-a-new-php-file/#findComment-264778 Share on other sites More sharing options...
papaface Posted May 30, 2007 Author Share Posted May 30, 2007 All I want to know is how to get the <?php ?> tags in the new file. Link to comment https://forums.phpfreaks.com/topic/53574-create-a-new-php-file/#findComment-264780 Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 This does not work ??? <?php $newfile = '<?php' . "\n" . ' $hello = "there";' . "\n" . ' $bye = "good";' . "\n" . ' ?>'; // note added the \n for fun. $fp = fopen('newfile.php'); fwrite($fp, $newfile); fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/53574-create-a-new-php-file/#findComment-264812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.