I have a small app I am working on that generates configuration files. Because it may be used to generate a few different variants of configurations, I gather the variable values from the user, and then read in a template configuration from a file. That file has the names of the variables in it (i.e. $ip_address) at the proper positions. I have set those variables in my php code before reading and the printing out the files. However, the variable names are printed out, not the values of the variables:
$hostname = $_POST['username'] . "_891";
$domain = $_POST['username'] . ".local";
$routerFile = "891.txt";
$file_handle = fopen($routerFile, "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
print $line . "<br />";
}
Output example:
hostname $hostname
ip domain-name $domain
How do I get php to replace the variables names with their stored values?