Loading template file and replacing placeholders I have an HTLP template file called "template.tmpl". In the template I have a few placeholders like {{NAME}} and {{USERNAME}}. I am then loading the template file into a variable called $template using file_get_contents. I then put the $template variable through a function which deals with replacing a series of placeholders. 

My code is below and seems to be working fine, but wanted some input if there was any way to improve or make it more efficient.

function replace_tags($string){
    $vars = array('{{NAME}}'=&gt;'Bob', '{{USERNAME}}'=&gt;'user_name', '&lt;?'=&gt;'', '?&gt;'=&gt;'');
    return str_replace(array_keys($vars), $vars, $string);
}

$template = file_get_contents('template.tmpl', true);

echo replace_tags($template);
I would say suggest writing your input like so:

function replace_tags($template, $placeholders){
    $placeholders = array_merge($placeholders, array('&lt;?'=&gt;'', '?&gt;'=&gt;''));
    return str_replace(array_keys($placeholders), $placeholders, $template);
}

$vars = array('{{NAME}}'=&gt;'Bob', '{{USERNAME}}'=&gt;'user_name');
$template = file_get_contents('template.tmpl', true);

echo replace_tags($template, $vars);


So that you can define the constant changes, and the changes you want to build depending on user, etc.