I am trying to simplify my code, I call the ob_start();
and ob_get_clean();
about 20 times, so to simplify the code, I have changed it from
ob_start();
include ROOT."/functions/generate/header.php";
$header= ob_get_clean();
To $header=get_content(ROOT."/functions/generate/header.php");
with the function as:
function get_content($file){
ob_start();
include $file;
return ob_get_clean();
}
But since turning the procedure into a function, I am no longer able to access the variables in the main form form the form I am calling like the header.php
file. The variables are not available when using the function, but if I use the longer version it allows me to access the variables.
Is there a reason for this or someway to work around it?