The if statement is used in alot of languages, but I'll show you what you can use it to in php. Think it like this. IF you have to pickup your son tomorrow early, you would set your alarm clock on. But if someone ELSE is picking him up, you dont have to set your alarm clock on. $alarm = false; if ($alarm == false){ echo "Someone else is picking him up."; } PHP: I'll explain the code above. $alarm = false; PHP: This line is that you have set your $alarm variable to false. if ($alarm == false){ PHP: This line tells us IF the variable $alarm equals false. echo "Someone else is picking him up."; PHP: This line prints the text "Someone else is picking him up.". } PHP: This line closes the IF statement. Overall, what this does if you put it together, that if the variable $alarm equals false, it will print the text "Someone else is picking him up.". That was only if someone picked up your son. You could also do it like this. If the $alarm variable equals false it says the text "Someone else is picking him up.", and if the variable $alarm isnt equal false, it will say something else. Like this: $alarm = true; if ($alarm == false){ echo "Someone else is picking him up."; } else { echo "Pick up your son!"; } PHP: The above code is like this. If the $alarm variable doesnt equal false it will say the text "Pick up your son!". It doesnt matter what you set the $alarm variable to. Because IF it doesnt equal false, it will ELSE say the other text. Okay, now, you could also do it like this. You have 2 different codes, one that if it equals false it will say "Someone else is picking him up.", and if it equals true it will say "Pick up your son!". The code would look something like this: $alarm = false; if ($alarm == false){ echo "Someone else is picking him up."; } if ($alarm == true){ echo "Pick up your son!"; } PHP: The code above is simple to understand. Like I explained before. If you now sat the $alarm variable at the top, to true, it would display the text "Pick up your son!" By the way, you could do this with numbers too. Like this: $alarm = 4; if ($alarm > 12){ echo "WAKE UP!"; } if ($alarm < 12){ echo "Just sleep more."; } PHP: The first part of the code: if ($alarm > 12){ echo "WAKE UP!"; } PHP: Tells us that if the $alarm variable is greater than 12 it will display the text "WAKE UP!" The second part of the code: if ($alarm < 12){ echo "Just sleep more."; } PHP: Tells us that if the $alarm variable is lesser than 12, it will display the text "Just keep sleeping." Okay, I think I explained enough now, hope you learned something If I did something wrong, tell me By the way, here is the Comparison operators:
A common bug. What if $alarm == 12 ? Most of the time, what's really called for is one > and one <=, or vice versa.