Difference between revisions of "PHP-and-MySQL/C2/Comparison-Operators /English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| border=1 !Time !Narration |- |0:00 |In this PHP tutorial we will learn about Comparison Operators. |- |0:04 |Comparison Operators can compare 2 values, 2 strings or 2 variable…')
 
(No difference)

Latest revision as of 12:01, 29 November 2012

Time Narration
0:00 In this PHP tutorial we will learn about Comparison Operators.
0:04 Comparison Operators can compare 2 values, 2 strings or 2 variables that can contain any of them and will act upon that.
0:12 For this I am going to use an IF statement.
0:19 Lets start by creating the IF statement structure.
0:30 My condition is if 1==1.
0:33 echo.
0:36 True.
0:39 and then else.
0:43 echo.
0:46 False. Remember I don't need these brackets so I'm going to take them out.
0:51 Lets indent it
0:53 Never mind the indenting.
0:58 This is the first comparison operator.
1:02 2 = to means comparison operator. We've seen this in the IF statement before.
1:06 1 does equal to 1 so this will echo True. Lets try it.
1:11 We got True.
1:13 Let me change this. IF 1 is greater than 1 then lets see what result we get.
1:27 False, because 1 is equal to 1 and not greater than 1.
1:33 Now lets change this to 1 greater than or equal to 1
1:36 IF 1 greater than or equal to 1, echo True otherwise echo False.
1:43 Here we should get True.
1:48 You can also do the same with less than or equal to. So for example less than
1:55 would be False, less than or equal to would be True.
2:01 We can also say not equal. So if 1 is not equal to 1 echo True
2:12 Refresh. We'll get False here because 1 is equal to 1. Now lets say if 1 isn't equal to 2
2:20 We get True because 1 is not equal to 2
2:25 These are the basic Comparison Operators that you will be using for our tutorials
2:33 Expand on this - practice them - and you'll understand them better
2:41 You can also compare variables using these operators. So for example num1 = 1
2:48 num2 = 2. All we now do is replace these values and there we go
2:58 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
3:05 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
3:21 These are the simple Comparison Operators. Play around with them. See what you can do. Thanks for watching.
3:30 This is Mad Madhur dubbing for the Spoken Tutorial Project.

Contributors and Content Editors

Chandrika