I have a php file with comments and code.
<?php
// Some comments
define('THING', 'thing1');
$variable = 'string1';
if ($statement === true) { echo 'true1'; }
I want to know the best way to edit this file to change the variables and spit out a new version of the file with the changes.
<?php
// Some comments
define('THING', 'thing2');
$variable = 'string2';
if ($statement === true) { echo 'true2'; }
The file is fairly large. I could write a function which adds together a massive string for output but all the escaping I would have to do with comments etc would be a headache.
I was thinking of including the file but this would just allow it's variables to be used within another class.
So far the only thing I can think of is to make a 'skeleton' version of the file (below) with the variables I want to change written into the file. I can assign them, but actually dumping it all back out to the file like either of the above examples has escaped me.
Best way of doing this?
<?php
// Some comments
define('THING', $thing);
$variable = $string;
if ($statement === true) { echo $true; }