[英]Does a php return exit out like break?
我當時在看這個函數,注意到有一些返回.... 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
}
}
它立即將函數留在它所調用的位置。
從函數返回。 查看文檔-http: //php.net/return
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.