Re: change variable in file
| From: | Jason Wong | Date: | Sun, 30 Jun 2002 13:33:48 +0000 |
| Subject: | Re: change variable in file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104571@lists.php.net to get a copy of this message | ||
On Sunday 30 June 2002 03:09, Nookie wrote:
> Hi,
>
> I want to write function which change variable in ie. config.php file ...
> Here is code:
>
> <?
>
> include "config.php";
>
> $file = fopen("config.php", "w+");
>
> $content = fread($file, filesize("config.php"));
>
> $content = str_replace("\$option['test'] = \"" .
> $option['test'] . "\";",
> "\$option['test'] = \"po tescie\";", $content);
>
> fwrite($file, $content);
>
> ?>
>
> and config.php:
>
> <?
>
> $option['test'] = "test";
>
> ?>
>
> and it's doesn't work :( ... when I run script, it clear config.php and
> nothing else ... where is my fault?
What does $content contain?
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
I'm still waiting for the advent of the computer science groupie.
*/