I have the following $_POST function to check if the fields of ‘start’, ‘middle’ and ‘end’ is empty or not.
if(!empty($_POST['start'])) {
$description = "a sentence".$_POST['start']." with something in the START.";
}
if(!empty($_POST['middle'])) {
$description = "a sentence".$_POST['middle']." with something in the MIDDLE.";
}
if(!empty($_POST['end'])) {
$description .= "a sentence".$_POST['end']." with something in the END.";
}
I want to check the values in one function, in other words I want to check multiple values at the same time. I have seen few method but not sure which one is right, using comma or && or ||, something like below …
if(!empty($_POST['start']) , (!empty($_POST['middle']) , (!empty($_POST['end']))
or
if(!empty($_POST['start']) && (!empty($_POST['middle']) && (!empty($_POST['end']))
or
if(!empty($_POST['start']) || (!empty($_POST['middle']) || (!empty($_POST['end']))
Can anyone tell me the right code for this kind of formation?
here are some basic.. i made it as a comment(as i was not sure if this is the thing you asked for) but i guess an answer would be appropriate with a bit of details.
the && will check every condition and if all are true it will return true…
take it like this
it will always return False and if will not execute because one of the condition is false
THe || will check the first condition if its true it will return true else check the second condition If all are false(not even a single is true) it will return false.
again following the previous example
now the compiler checks the first condition if its true it will ignore the next two conditions and return true.
if(FALSE || FALSE || FALSE)– this will return false as all are falseif you , operatior then the last condition to the right will be evaluated and if it is true then it will return true else false
example
so choose the operator according to your logic.
USE THIS :