Basically there would be some sort of template function which
Firstly extracts the template whether it in Directories or in a database.
The {stuff}
Would normally have either str_replace(); or Regex.
Eg..
<html>
<head>
<title>{title}</title>
then in php
$string = str_replace("{title}","Hey it worked",$string);
it will print out
<html>
<head>
<title>Hey it worked</title>..
There are some Template tutorials.. Go to google.com and search PHP Templates or Template Tutorials for PHP.