1 00:00:00 --> 00:00:04 In this PHP tutorial we will learn about Comparison Operators. 2 00:00:05 --> 00:00:14 Comparison Operators can compare 2 values, 2 strings or 2 variables that can contain any of them and will act upon that. 3 00:00:15 --> 00:00:18 For this I am going to use an IF statement. 4 00:00:19 --> 00:00:24 Lets start by creating the IF statement structure. 5 00:00:25 --> 00:00:29 My condition is if 1==1. 6 00:00:30 --> 00:00:32 echo. 7 00:00:33 --> 00:00:36 True. 8 00:00:37 --> 00:00:41 and then else. 9 00:00:42 --> 00:00:43 echo. 10 00:00:44 --> 00:00:50 False. Remember I don't need these brackets so I'm going to take them out. 11 00:00:51 --> 00:00:55 Lets indent it 12 00:00:56 --> 00:00:58 Never mind the indenting. 13 00:00:59 --> 00:01:01 This is the first comparison operator. 14 00:01:02 --> 00:01:07 Two = to means comparison operator. We've seen this in the IF statement before. 15 00:01:08 --> 00:01:12 1 does equal to 1 so this will echo True. Lets try it. 16 00:01:13 --> 00:01:14 We got True. 17 00:01:15 --> 00:01:26 Let me change this. IF 1 is greater than 1 then lets see what result we get. 18 00:01:27 --> 00:01:32 False, because 1 is equal to 1 and not greater than 1. 19 00:01:33 --> 00:01:36 Now lets change this to 1 greater than or equal to 1 20 00:01:37 --> 00:01:44 IF 1 greater than or equal to 1, echo True else echo False. 21 00:01:45 --> 00:01:47 Here we should get True. 22 00:01:48 --> 00:01:54 You can also do the same with less than or equal to. So for example less than 23 00:01:55 --> 00:02:00 would be False, less than or equal to would be True. 24 00:02:01 --> 00:02:10 We can also say not equal. So if 1 is not equal to 1 echo True 25 00:02:11 --> 00:02:19 Refresh. We'll get False here because 1 is equal to 1. Now lets say if 1 isn't equal to 2 26 00:02:20 --> 00:02:24 We get True because 1 is not equal to 2 27 00:02:25 --> 00:02:32 These are the basic Comparison Operators that you will be using for our tutorials 28 00:02:33 --> 00:02:39 Expand on this - practice them - and you'll understand them better 29 00:02:40 --> 00:02:47 You can also compare variables using these operators. So for example num1 = 1 30 00:02:48 --> 00:03:00 num2 = 2. All we now do is replace these values and there we go 31 00:03:01 --> 00:03:10 This will produce exactly the same result as we've got earlier - which is True. Now all we need to do is change these values 32 00:03:11 --> 00:03:23 Please note this will now read as num1 = 1 num2 = 1 so if num1 doesn't equal 1 it is False because 1 does equal 1 therefore we get False 33 00:03:24 --> 00:03:32 These here are the simple Comparison Operators. Play around with them. See what you can do. Thanks for watching. 34 00:03:33 --> 00:03:38 This is Mad Madhur dubbing for the Spoken Tutorial Project.