Updating parts of files without rewriting them
| From: | Jeff Lewis | Date: | Sun, 02 Dec 2001 02:31:48 +0000 |
| Subject: | Updating parts of files without rewriting them | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76333@lists.php.net to get a copy of this message | ||
I have a file that contains settings and there are a lot of comments in
there and a lot of variables. An excerpt of the file looks like below. My
question is, is it possible to change only certain variables? For example,
I want to set just the db variables, is it possible for me to input the new
values in a form and replace only those in the file without having to
rewrite the entire file?
$mailtype = 0; # 0 - sendmail, 1 - SMTP
########## Database Info ##########
$db_name = "name";
$db_user = "user";
$db_passwd = "pass";
$db_server = "localhost";
########## Directories/Files ##########
# Note: directories other than $imagesdir do not have to be changed unless
you move things
$boarddir = "."; # The absolute path to the folder (usually can be left
as '.')
$sourcedir = "./Sources"; # Directory with source files