PHP - how to use a variables that inside an if statement without using global
I'm trying to pull out two variables values out from a function without no
need to use global and of course we are going to use this function at
another page.
function get_selected_page(){
if (isset($_GET['subj'])) {
$sel_subject = get_subject_by_id($_GET['subj']);
$sel_page = NULL;
} elseif (isset($_GET['page'])) {
$sel_page = get_page_by_id($_GET['page']);
$sel_subject = NULL;
} else {
$sel_subject = NULL;
$sel_page = NULL;
}
}
The variables are $sel_subject and $sel_page
No comments:
Post a Comment