I'm trying to make a simple little templating system where I don't want to define every variable that's available in the template. For example.
Every page would have
<?php displayHTML($variable); ?>
but only some pages would actually have $variable defined.
$variable = "something";
In included functions.php I have tried
function displayHTML($variable){
if(isset($variable)){
echo $variable;
}else{
echo '';
}
}
But the error seems to be coming from the fact that $variable isn't defined rather than not being set with a value. This error only shows with E_ALL enabled and I know I can shut it with @ or simply defining $variable across the board. Any function or best practice to avoid having to do this?
I know this seems weird but I would like to option to not define every variable if its not gonna be used on a page.