2011-04-04 84 views
1

我看着这个功能,并注意到一些回报....没有一个PHP返乡离场的功能还是它继续下来,直到底部php会返回退出吗?

function confirmUser($username, $password) { 
    global $conn; /* Add slashes if necessary (for query) */ 
    if (!get_magic_quotes_gpc()) { 
     $username = addslashes($username); 
    } 

    /* Verify that user is in database */ 
    $q = "select password from users where username = '$username'"; 
    $result = mysql_query($q, $conn); 
    if (!$result || (mysql_numrows($result) < 1)) { 
     return 1; //Indicates username failure 
    } 

    /* Retrieve password from result, strip slashes */ 
    $dbarray = mysql_fetch_array($result); 
    $dbarray['password'] = stripslashes($dbarray['password']); 
    $password = stripslashes($password); 

    /* Validate that password is correct */ 
    if ($password == $dbarray['password']) { 
     return 0; //Success! Username and password confirmed 
    } else { 
     return 2; //Indicates password failure 
    } 
} 
+2

'return'让你离开函数并返回调用该函数的控件。 – EmCo 2011-04-04 03:13:16

回答

4

正好离开功能在它被称为地方。