Read file with variable replaced!

Hello

I have a main file that calls another file.

In the main file there are query string variables like :

$_GET['name']
$_GET['email']

Other file, that is called using file_get_contents in the main file is template.php
in template.php there is a massive use of all those $_GET variables.

Now, I do not want to use str_replace thing, but still i want that if I use the below code :

$contents = file_get_contents("template.php");

It should give me the contents in the template.php with the data placed where the $_GET variables are used.

If I use include(“template.php”); it works well, but with that I can put the contents in a variable. like

$contents = include("template.php");

Please guide me !

Thanks
Zeeshan

That’s not a native function of PHP. Smarty does a similar job though, which uses markers within the included file to indicate where you want the variables to be added.

does it mean there is no way except using str_replace ?

ob_start()
include
ob_get_clean()