Think for yourself. The comparison itself returns true or false by itself, right?
Let's go further. The first part is true if and only if login was root, right? And the second - if the pass was 123321. That is, everything together will be true if the login root, and pass 123321. And of course false otherwise.
You see that no if
are needed.
That is, in principle, the function could be rewritten with if
's, in a more familiar way, like this:
function check_login($login, $pass) { $result = ($_POST['login'] == 'root') && ($_POST['pass'] == '123321'); if ($result == true) { return true; } else { return false; } }
Or so:
function check_login($login, $pass) { $result = ($_POST['login'] == 'root') && ($_POST['pass'] == '123321'); if ($result == true) { return $result; } else { return $result; } }
But why?