Acers
06-08-2006, 05:56 PM
I am trying to build something for which i would need to modify a files content via another file.
eg i have say 2 files file1.php and file2.php
i want to modify the content of file2.php(in that just one line i have to modify. supposing it reads
$varid={some name};
Now there is some other code in file2.php also which is static.
what i want to do is to execute file1.php and from a variable thats generated there (i get value of {some name} from file 1, i update the file2.php.
possible? i read that creating a new file2.php might do this also.
<?php
$fn = "file2.php";
$file = fopen($fn, "w+");
$size = filesize($fn);
$filecontents=(full contents of file with {Some name} added
if($somecondition) fwrite($file, $filecontents);
fclose($file);
?>
could there be a search replace kinda function or the above way is only way?
eg i have say 2 files file1.php and file2.php
i want to modify the content of file2.php(in that just one line i have to modify. supposing it reads
$varid={some name};
Now there is some other code in file2.php also which is static.
what i want to do is to execute file1.php and from a variable thats generated there (i get value of {some name} from file 1, i update the file2.php.
possible? i read that creating a new file2.php might do this also.
<?php
$fn = "file2.php";
$file = fopen($fn, "w+");
$size = filesize($fn);
$filecontents=(full contents of file with {Some name} added
if($somecondition) fwrite($file, $filecontents);
fclose($file);
?>
could there be a search replace kinda function or the above way is only way?