easy way for php function to write to settings file
<p>I have the follwing code writing to a settings file. </p>

<pre><code> $data=json_decode($_REQUEST["data"],true);
 $dbhost=$data["dbhost"];
 $dbuser=$data["dbuser"];
 $dbpass=$data["dbpass"];
 $dbname=$data["dbname"];
 $config="&lt;?php @define('DB_HOST', '$dbhost');
 @define('DB_USER_ID', '$dbuser');
 @define('DB_USER_PASS', '$dbpass');
 @define('DB_NAME', '$dbname'); ?&gt;";

 $fp = fopen("../settings/settings.php", "w");
 fwrite($fp, $config);
 fclose($fp);
</code></pre>

<p>The settings.php looks like this</p>

<pre><code> @define('DB_HOST', '');
 @define('DB_USER_ID', '');
 @define('DB_USER_PASS', '');
 @define('DB_NAME', '');
</code></pre>

<p>I would like to replace it with a much easier way to write the empty values since the current code writes the whole file, it doesnt update the values. I know i could use a unique identifier but it is possible to write the empty values instead?</p>

<p>UPDATE :</p>

<p>I also have in that settings.php file some settings based on true or false and this is where i get stuck writing the values.</p>

<pre><code> define('LOGO_IMAGE_PATH', '%logo_image%');
 define('USE_LOGO_IMAGE', true);
 define('SITE_TITLE', '%site_title%');
 define('TRACK_IP', false);
 define('MOBILE_VERSION_ENABLED', false);
</code></pre>

<p>I couldnt get the function to update the true or false values only if i write the file with the same method like above</p>

<p>Thank you for the help.</p>
