Greetings, I’m new to this community and relatively new to PHP and I have a question about the possible use for true/false values. I’m working on a login script for my site and I want to display errors if the information entered has a problem.
I’m planning on using the following code that acts if no errors are present: if(!$ID_check->error && !$password_check->error){
$user = new login($ID_check->check_this, $password_check->check_this);
$user->login_user();
}
This basically says that if $ID_check->error and $password_check->error are set to false then log the user in. I am fairly confident that the usage of this is proper.
This follows it up://Example 1)
if($ID_check->error or $password_check->error){
$error = true;
}
I’m assuming that if $ID_check->error or $password_check->error are set to true it will then set the $error value to true as well. This usage however is where my question comes in. Can the code remain this way or would it be better to replace is with: //Example 2)
if($ID_check->error == true or $password_check->error == true){
$error = true;
}
So is it better to use Example 1 or Example 2 or is there a better way ? I have used Example 1 before and it seems to work fine, but I don’t know if the if() statement is just reacting to whether or not the value is set or what exactly is going on.
Thanks!