Hello,
I am looking for a way to stop variable scope leakage.
I have a class with a function to include a page something like this:
class functions{
function getView($viewTheme, $viewType, $viewTask, $viewFunction, $pageID=null, $itemID=null){
$baseView = ROOTME.DIR_VIEWS.$viewType.'/'.$viewTheme.'/'.BASE_VIEW_DIR.$viewTask.'/'.$viewFunction.'.php';
if(file_exists($baseView)){
include($baseView);
}
}
}
My problem is, I am now wanting to reuse this function in some of the pages multiple times include, but the variables $viewTheme, $viewType, $viewTask, $viewFunction, $pageID, $itemID are needed again after the next call of the function, and they are overwritten by the next call of the function.
Is there a way to prevent this? For example make variables stay inside the function call and and only usable by the file it includes - and if that calls the function again, it again has its own variables?
Kind regards, and thanks in advance!