In PHP7 app, I have created helper method to include my template files.
class Templates
{
public static function Load($name)
{
include Config::template_dir."/tpl.{$name}.php";
}
}
$var = "Item";
Templates::Load("menu");
and tpl.menu.php is only
<?=$var?>
However, this is not working (Undefined variable $var) , since $var is not visible inside Load. How can I use this solution with a Load method, but be able to use global variables in included file? I dont like putting include directly into my code, since it just does not look clean.
I have solved this with variarible-length argument list
And call with