Writing a configuration file in PHP
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7053947/writing-to-a-php-file">writing to a .php file?</a>  </p>
</blockquote>



<p>So I have a config.php file for a CMS that I created from scratch. This file has the structure shown below:</p>

<pre><code>&lt;?php

date_default_timezone_set( "America/Phoenix" );
define( "DB_HOST_USER", "mysql:host=localhost;dbname=db_cms" );
define( "DB_USERNAME", "username" );
define( "DB_PASSWORD", "password" );
define( "CMS_TITLE", "Sample Title");
define( "USERNAME", "cms_user");
define( "PASSWORD", "cms_password");

?&gt;
</code></pre>

<p>My question is that how can I write into this file and save it to the disk using PHP.
Help would be greatly appreciated.</p>

<p>Edit: I saw that WordPress uses similar kind of file structure to store user/application configuration as outlined <a href="http://phpxref.com/xref/wordpress/wp-config-sample.php.source.html" rel="nofollow">here</a>. I was just wondering if I can change above file (config.php) and store new setting in there. For instance, I want to set USERNAME to blog_user (<code>define( "USERNAME", "blog_user");</code>). Is it possible to just store this change without rewriting the entire file?</p>
