Hi, everyone I have a question about PHP code, I want to write a code so that many conditions must be accepted before proceeding to the next step:- for example:- if jean go to school and he did homework and his grade was A and his attendance complete..........give him a sandwich, how can I make this in PHP, I am familiar with the rule of IF but Idon't know how to make many conditions "not only one" to be verified before going to the next step and do the order
if ( value1 = condition1 && value2 = condition2 && value3 = condition3) { // All of the above are true } else { // Not all conditions were met } PHP: The same for OR - you just need to replace && with ||.
Yes, exactly what blink says. // under the assumption you are setting all these variables to true or false earlier in your script if ($jean_school && $jean_homework && $jean_grade && $jean_attendence_awesome){ $jean_sandwich = true; } else $jean_is_a_loser = true; } PHP:
Blink's got it, but I'd nitpick a bit about the syntax for clarity: if ( (value1 == condition1) && (value2 == condition2) && (value3 == condition3) ) { // All of the above are true } else { // Not all conditions were met } PHP:
Then you aren't familiar with the IF statement...at all. Goto the PHP website they explain this in detail