Trying to improve my skills by creating a couple of scripts from scratch, i've been referencing an ancient script and can't figure out why something has been done the way it as. [code below]

I'm guessing it has been done to create some sort of template system. But what alternative would there be ? as i understand this is not the best way to do it.

At the end of the script it runs everything through 2 functions parse_if and parse

Code PHP:
        $style_gallery = parse_if ( $style_gallery, 'there_is_album_description', $description != '' );
        $style_gallery = parse_if ( $style_gallery, 'there_are_pages', $pages_links !== '' );
        $style_gallery = parse_if ( $style_gallery, 'browse_albums', 1 );
        $style_gallery = parse_if ( $style_gallery, 'view_image', 0 );
        $style_gallery = parse_if ( $style_gallery, 'there_are_albums', $albums_count );
        $style_gallery = parse_if ( $style_gallery, 'there_are_images', $images_count );
        print parse ( $style_gallery, array ( '{navigation}' => $navigation, '{show_albums}' => $albums_table, '{show_images}' => $images_table, '{show_pages}' => $pages_links, '{show_album_description}' => $description ) );

Code PHP:
function parse ( &$template, $data, $x = '' )
{
    if ( !is_array ( $data ) )
    {
        return str_replace ($data, $x, $template);
    }
    else
    {
        return str_replace ( array_keys($data), array_values($data), $template );
    }
}
 
function parse_if ( &$template, $varname, $varval, $false_replace = '' )
{
    $$varname = $varval;
    return preg_replace ( '#{if ' . $varname . '}(.+?){endif ' . $varname .'}#ise', '($' . $varname . ')?"$1":"$false_replace"', $template );
}

finally it is passed to a 'template'

Code PHP:
$style_gallery = <<<EOT
 
<html>
..
</html>
 
EOT;

So has this been done solely for the benefit of the template? is this a good way to go about it? what is the alternative? hope this makes sense i'm still a beginner