Hello, I want to do the following, I am going to generate equipment configuration templates and the user previously defines certain values that are key for the generation of that template, so my idea so that my php file is not huge is to put the template in a txt and read it from php replacing the variables that the user already defined, it would be something like this:
the php has the following (the variables are taken from a form, but I put it like this to make it simpler):
<?php
$valor1= "azul";
$valor2= "rojo";
$valor3= "verde";
$plantilla=fopen("fortinet.txt","r") or die("error al leer archivo");
while(!feof($plantilla))
{
$plantillaFinal = fgets($plantilla);
$plantillaFinal = nl2br($plantillaFinal);
echo $plantillaFinal;
}
?>
the txt has the following content:
edit 1
set name $valor1
set color $valor2
set policy $valor3
set bandwidth $valor4
end
The issue is that when the content of the txt is displayed, the variable is not replaced. I hope you can help me, greetings!
Try like this:
To get:
I hope it helps you. Leave me any questions in the comments to complete the answer.