PHP Logical Operators

in this episode we're going to talk about something called logical operators inside PHP and as you guys can see you to access some stuff in screen already we have x which is equal to 10 and we have y which is equal to 20 now the basic idea behind logical operators is that can actually go ahead and add more statements or more conditions inside something like an if statement for example and as you guys conceived to actually have an if statement down here and if you guys don't remember an if statement basically says if whatever is inside the parentheses a true then it's going to do whatever's down here now in this case I did actually put in X and asked if it was equal to Y and in this case it's not so it's actually not going to put not true because this statement is false so we're going to refresh the browser

you guys can see it does actually not say anything now logical operators basically at last was to combine multiple statements like conditions next to each other so we can actually check for more things than just one thing so if i go after the why we have here and say or and add another condition for example I could ask if one is in fact equal to 1 which is actually a true because one is actually equal to wonder the same you can actually see that we do actually get true inside the browser because right now it's checking if this is true or if this is true then do this down here and in this case one of them is actually true so it's just going to do whatever is down here now we can also use another one called and in between here which basically says that both of these statements has to be true so if actually go ahead and refresh the browser you guys can see that it does not write anything because this one is in fact false if a director government chains x220 you guys will see that now both statements actually true and it does actually say true so there's a couple different ways we can actually write this and i do want to recommend or not recommend i prefer writing it the other way because it does actually look a little bit cooler instead of using or what you're gonna go ahead and use d symbols here and I don't actually know they're called in english but it's a vertical line going you know up and down and if you have to the next to each other they will in fact do the same thing as writing or so if you actually save this and go refresh the browser you guys can see doesn't actually say true cause of the vaccines the ex back to 10 so only one statement down here is actually true and it still writes out true because it's taking or another and now if you want to write symbols or these two symbols for end we can actually write ampersand ampersand was just exact same thing as writing and so if i refresh the browser you guys conceives that's nothing because one of these conditions are in fact false now we have another one which is called X or like this which basically says that one of these conditions has to be true but they can only one condition that has to be true we need that right now one is in fact equal to 1 x is not equal to Y so it will in fact print something out in the screen as you guys can see here now if you actually chains x220 again so now x is in fact equal to Y both these conditions will be true but if I go refresh the browser you can see it says that is false and that's because we is basically saying here that one of these conditions has to be true but we can't have both of them being true so that's the basic logical operators who do actually have inside PSP we will be using these as well at some point usually when you do more complicated stuff or not complicated stuff but usually we do something that's not very very basic you do usually used these kind of conditions here so i hope you guys enjoyed this episode in the next episode we're going to start talking about these if statements are actually going to talk about all the different types of statements we have that are similar to the if statement so we have enjoyed it and I'll see you guys next time