im having this function to call templates with .html extension from templates folder because i want to separate html from php
ok this is my function for calling template
class Template {
public $temp;
// function for reading the template from a directory
function gettemplate($template) {
// check if path is folder
if (is_dir('templates/')) {
// check if file exists and if is readable
if (is_readable('templates/' . $template . '.html')) {
$this->temp = 'templates/' . $template . '.html';
return $this->temp;
} else {
return false;
}
} else {
return false;
}
}
This class calling template from templates folder
now what i need is to make example profile.html and profile.php
in profile.html just make variables like First name : <?php echo $first_name; ?>
and in profile.php to define varibales here is profile.php
if (isset($_GET['id']) && !empty($_GET['id']) && is_numeric($_GET['id'])) {
$id = $filters->validate_url($_GET['id']);
$data = $users->userdata($id);
$id = $data['user_id'];
$first_name = $data['first_name'];
$last_name = $data['last_name'];
$username = $data['username'];
$email = $data['email'];
$country = $data['country'];
$date = $data['date'];
include ( $template->gettemplate('profile') );
and here is profile.html
<ul>
<li>First name : <?php echo $first_name; ?></li>
<li>Last name : <?php echo $last_name; ?></li>
<li>Username : <?php echo $username; ?></li>
<li>Email : <?php echo $email; ?></li>
<li>Country : <?php echo $country; ?></li>
<li>Member since : <?php echo $date; ?></li>
now my question is how do i make class to call template file just with
$template->gettemplate('profile');
and not with include ($template->gettemplate('profile'));
and to display variables from php file in html file