I have a situation where i've used a session variable to store a user's custom session privilege to be used to determine which version of a table to show based on the user's predefined privilege. (a one character VARCHAR string which is set to 0, 1, or 2 in the SQL table where 0 means banned, 1 means regular user, and 2 means app administrator). Can I declare in a function "return priv" and use it like the following, or does "return" work differently in a function?
Code:
<?php
function privcheck() {
$priv = $_SESSION['priv'] ;
return $priv;
}
if ( privcheck()=== 0) {
echo 'do code for case 0';
}
if ( privcheck() ===1) {
echo 'do code for case 1';
}
if ( privcheck() ===2) {
echo 'do code for case 2';
}
exit;
?>
Comment