Far Cry Posted December 22, 2012 Share Posted December 22, 2012 <?php class Session { public $loggedin; public function CheckLogin($userid,$username) { if(isset($userid) && isset($username)){ $this->loggedin = true; } else { $this->loggedin = false; } return $this->loggedin; } public function Login(){ if($this->CheckLogin(....?)){ } } } ?> Would I need to pass the variables to the CheckLogin function in the if statement to get the true/false value? If so, how? Quote Link to comment https://forums.phpfreaks.com/topic/272292-php-functions-within-if-statements/ Share on other sites More sharing options...
cpd Posted December 22, 2012 Share Posted December 22, 2012 Of course you would. If a method or function has compulsory parameters you must supply them regardless of where you're calling it from. Quote Link to comment https://forums.phpfreaks.com/topic/272292-php-functions-within-if-statements/#findComment-1400919 Share on other sites More sharing options...
Jessica Posted December 23, 2012 Share Posted December 23, 2012 Your login function will need arguments, especially since its going to do something besides just wrap check login. Quote Link to comment https://forums.phpfreaks.com/topic/272292-php-functions-within-if-statements/#findComment-1400957 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.