[英]php exit while loop inside a function
I have a function that return a value by checking an exiting details in database mysql inside the function I have a while loop by an array from sql query. 我有一个通过检查数据库mysql中存在的详细信息来返回值的函数,该函数由sql查询中的数组进行while循环。 I want to break the while loop if its find a mach how should I do it ?
我想打断while循环,如果找到一个马赫,我该怎么办?
this is my code: 这是我的代码:
function chklogin()
{
$query = mysql_query("SELECT * FROM sg_loginlastauthentication WHERE uid = '$autoid' ");
$checkLogin = mysql_num_rows($query);
if ($checkLogin==0)
{
return "FALSE"; // auth fail
}
elseif ($checkLogin>1)
{
while($row = mysqli_fetch_array($query))
{
$userip = $row['uipadd'];
$userra = $row['randomnu'];
$userid = $row['uid'];
$cookieipadd = md5(md5(getclientip()));
$authdb = md5($userid + $userip + $userra);
$authusco = md5($userid + $cookieipadd + $userra);
if ($authdb==$authusco) //ok
{
return "TRUE";
}
}
}
}
does the "return true" is breaking the loop or I need to place a "break;" “ return true”是否打破了循环,还是我需要放置“ break”? before/after the "return" ?
“返回”之前/之后?
break
after return break
If called from within a function, the return statement immediately ends execution of the current function.
如果从函数内部调用,则return语句将立即结束当前函数的执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.