Ok this may be an elementary question, but I want an informed answer and I can’t seem to get the keywords right to get an answer through google. If this is a duplicate please close it and point me in the right direction.
So here’s the question. In the code below, when the break that’s pointed to is executed, where does it break out too?
case 'changeEmployeeInfo':
$con = db_connect(DBNAME, DBUSERNAME, DBPASSWORD , DBHOST);
$query = 'UPDATE USERS SET firstname = ?, lastname = ?, email = ? where idusers = ?';
$updateValues = array($firstName,$lastName,$email,$employeeID);
$newID = db_change($query,$updateValues,$con);
if($_SESSION['role']==1||$_SESSION['role']==3||$_SESSION['role']==4){
if($_POST['status']== true){
$status = 1;
}elseif($_POST['status']==false){
$status = 0;
}
else{
break;//<--THIS IS THE BREAK I'M TALKING ABOUT
}
$query = 'UPDATE USERS SET status = ? where idusers = ?';
$updateValues = array($status, $employeeID);
$newID = db_change($query,$updateValues,$con);
}
db_disconnect($con);
break;
My instinct tells me that the db_disconnect function will still be executed but the UPDATE USERS query and it’s associated lines will not be. Am I correct in thinking this? Thanks!
breakin PHP breaks exactly one level, in your case thecase. To break more levels, usebreak n:From the documentation: