I have these three functions inside the same class:
public function checkLogin() {
    if(isset($this->getSessionVal())) {
        return true;
    } else {
        return false;
    }
}
public function getSessionVal($type = 'user') {
    return $this->sanitise($_SESSION[$type]);
}
public function sanitise($input) {
    $input = trim($input);
    if (get_magic_quotes_gpc()) {
         $input = stripslashes($input);
    }
    if($this->conn) {
        $input = mysql_real_escape_string($input);  
    }
    $input = strip_tags($input);
    return $input;
}
When I use the above it white-screens and prints nothing, so typically a syntax error, but it's not syntax (Dreamweaver doesn't show up any, and I'm sure it's not. If I change checkLogin to the following:
public function checkLogin() {
    if(isset($_SESSION['user'])) {
        return true;
    } else {
        return false;
    }
}
The sa开发者_开发问答nitise function is fine, I took that out of getSessionVal and it still white-screeened. I'm completely confused, to me it makes no sense so I have someone has an idea (I know I could do it the way it works, but I want to understand why this doesn't work).
Thanks in advance!
 if(isset($this->getSessionVal())) {
isset() is a language construct. You can not pass it a function call as a parameter.
Activate error reporting - you should get an error message.
As a workaround, you could e.g. have getSessionVal() return false if the session variable was not set. (That is if false is not a possible value of what you are returning, of course.)
You would then move the isset into getSessionVal() , and test for false in checkLogin().
Remove the isset() when calling the other method in the class.
public function checkLogin() {
    if($this->getSessionVal()) {
        return true;
    } else {
        return false;
    }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论