I have this simple function
function render($template, $values = [])
{
// if template exists, render it
if (file_exists("../templates/$template"))
{
// extract variables into local scope
extract($values);
// render header
require("../templates/header.php");
// render template
require("../templates/$template");
// render footer
require("../templates/footer.php");
}
// else err
else
{
trigger_error("Invalid template: $template", E_USER_ERROR);
}
This works fine when I am working on my localhost, but when I uploaded the files on my webhost and this function is used in a php file as follows->
<?php
// configuration
require("../includes/config.php");
render("mainpage_template.php", ["title" => "Welcome "]);
?>
I get this parse error written in the title.Why is it working only on my localmachine?