I have this model class that has several functions in it. I need to get the variable $new_route after its been set by the if statements to be available to all the other functions. I included them initially at the top of the class, not in a function, but the if statements kill that. I can include those lines of code in every function and it works the way I want, but I know that way sucks. I wrapped the code in a function getRoute() but how do I execute the function inside the class automatically so that the variables are available for all the other functions?
public function getRoute() {
$find_route = $_SERVER['QUERY_STRING'];
$get_route = explode('&',$find_route);
$set_route = explode('/',$get_route[0]);
$new_route = $set_route[1];
if ($new_route == 'memberships'){
$new_route = "MEMBER";
}elseif ($new_route == 'donations'){
$new_route = "DONATE";
}elseif ($new_route == 'tickets'){
$new_route = "TICKET";
}elseif ($new_route == 'items'){
$new_route = "ITEM";
}elseif ($new_route == 'peer'){
$new_route = "PEER";
}elseif ($new_route == 'recurring'){
$new_route = "RECURRING";
}
return $new_route;
}