using $this->$Var to call an existing method-Collection of common programming errors
I’m in the process of creating a controller to display pages. I currently have this;
$request = str_replace("/Smarty/", "", $_SERVER['REQUEST_URI']);
$params = explode("/", $request);
function FormatArr ($Arr){
$Array_Keys = array ("PageName","Username");
if (count($Arr) > 2){
trigger_error("Unexpected Params",E_USER_ERROR);
}
return array_combine($Array_Keys,$Arr);
}
$New_Params = FormatArr($params);
On the setup.php page, then on my libs:
class testing {
protected $Smarty;
protected $fixpath;
public function __construct($Template_Name){
$this->Smarty = new Smarty;
$this->fixpath = dirname(__FILE__)."./Templates/".$Template_Name;
$this->Smarty->compile_dir=$this->fixpath."/compile";
$this->Smarty->template_dir=$this->fixpath."/html";
}
public function index(){
$this->Smarty->assign("name","test");
$this->Smarty->assign("test","../test/");
}
public function Display_Page($PageName){
$this->$PageName();
$this->Smarty->display($PageName.".html");
}
}
$Test = new testing('Testing/');
I have it sucessfully working, but I want to dynamically call pages which will render the correct variables on the smarty template. The problem is caused by:
$this->$PageName;
I’m struggling on finding the way of making this sucessfully call the necessary method