quadrant6
10-05-2006, 12:32 AM
The idea is that instead of repeating this sort of thing at the top of my scripts:
$id = $_REQUEST['id'];
if($id == '')
...
..I can simply have a function called int_var and do this
function int_var($var){
if(!isset($_REQUEST[$var]) && !isset($_SESSION[$var])){
echo "Error: This page requires the variable '<b>".$var."</b>' to be passed";
exit;
}
if($_REQUEST[$var] != ''){
$$var = $_REQUEST[$var];
} else if($_SESSION[$var] != ''){
$$variable = $_SESSION[$var];
}
}
// this page expects either $_REQUEST['id'] or $_SESSION['id']
int_var('id');
What I should end up with from this example above is
$id = '2';
But it just doesn't seem to be creating the $id variable.
Any suggestions?
$id = $_REQUEST['id'];
if($id == '')
...
..I can simply have a function called int_var and do this
function int_var($var){
if(!isset($_REQUEST[$var]) && !isset($_SESSION[$var])){
echo "Error: This page requires the variable '<b>".$var."</b>' to be passed";
exit;
}
if($_REQUEST[$var] != ''){
$$var = $_REQUEST[$var];
} else if($_SESSION[$var] != ''){
$$variable = $_SESSION[$var];
}
}
// this page expects either $_REQUEST['id'] or $_SESSION['id']
int_var('id');
What I should end up with from this example above is
$id = '2';
But it just doesn't seem to be creating the $id variable.
Any suggestions?