// Switch case to handle $page and the variable function call+associated value switch($page) { case 'index': $func = 'getNews'; $userFuncValue = 3; $altFuncValue = $_REQUEST['id']; break; case 'profile': $func = 'getProfile'; $userFuncValue = $_SESSION['UserID']; break; case 'messages': $func = 'getMessages'; $userFuncValue = $_SESSION['UserID']; break; } // Set vars from the called function to fill out the template. $tpl->set_vars($func($userFuncValue, $altFuncValue));