PHP simple template loader
This is not a template class at all, but sort of a wrapper for file_exists() function. It does nothing of the templating business but just gets you a filename.

To make it a template class, 


make it accept an array with all data used in the template
add a render() function that will extract data array into separate variables and then include the template file.
add some sort of auto-escaping feature (like going through the data array recursively and escaping all scalar values)
a possibility to return the rendered HTML instead of outputting it
add some facility to call a "master" template that will add the common site design to the certain page's template.


So a usage example would be

require_once 'Template.class.php';
$data = [
    'data' =&gt; $data,
    'results' =&gt; $results,
];
$template = new Template('path/to/template/file');
$template-&gt;render($data);


Quite off topic but consider a more tidy syntax for your template.

      &lt;div class="wrapper"&gt;
        &lt;?php foreach($data as $row): ?&gt;
          &lt;span&gt;&lt;small class="text-uppercase"&gt;&lt;?= $row['h'] ?&gt;&lt;/small&gt;
          &lt;small&gt;&amp;nbsp;-&amp;nbsp;&lt;/small&gt;
          &lt;small class="text-uppercase"&gt;&lt;?= $row['a'] ?&gt;&lt;/small&gt;
          &lt;p&gt;&lt;?= $results[mt_rand(1,12)] ?&gt;&lt;/p&gt;&lt;/span&gt;
        &lt;?php endforeach ?&gt;
      &lt;/div&gt;