jj20051 Posted September 13, 2010 Share Posted September 13, 2010 Alright so I'm attempting to save config data via php. Bellow is the code I currently have, however I'm afraid that when I "flip the switch" and use it that it will error out because of the <?php and ?> tags inside of it... Ideas, suggestions? $config = '../includes/config.php'; $fh = fopen($config, 'w'); $data = ' <?php $dbhost = "'.$database_host.'"; $dbuser = "'.$database_username.'"; $dbpass = "'.$database_password.'"; $dbname = "'.$database_name.'"; $key = "'.$site_key.'"; $cron_key = "'.$database_cron_key.'"; ?> '; fwrite($fh, $data); fclose($fh); Link to comment https://forums.phpfreaks.com/topic/213264-php-code-fopen-writing-php-code/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 13, 2010 Share Posted September 13, 2010 suggestions? Yes, try it and observe if it does what you expect. That's how most learning takes place. Link to comment https://forums.phpfreaks.com/topic/213264-php-code-fopen-writing-php-code/#findComment-1110454 Share on other sites More sharing options...
jj20051 Posted September 13, 2010 Author Share Posted September 13, 2010 The major problem being: I only want to try it once... I suppose I could create a separate test page with just that piece of code + the variables. Edit Update: Well apparently PHP has some form of a prevention mechanism to ensure that this works -- So apparently I'm already right... Sorry to have bugged anyone. Link to comment https://forums.phpfreaks.com/topic/213264-php-code-fopen-writing-php-code/#findComment-1110455 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.