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

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(4 intermediate revisions by the same user not shown)
Line 10: Line 10:
 
|-
 
|-
 
|00:18
 
|00:18
|What is a '''logical operator'''? Let's add a bit of logic and say it's the 'and' or the horizontal line operator.   
+
|What is a '''logical operator'''? Let's add a bit of logic and say it's the '''AND''' or the '''OR''' operator.   
 
|-
 
|-
 
|00:27
 
|00:27
|Now if I start creating my basic layout for my "if" statement, I will get to work on showing you what you can do with these.  
+
|Now, if I start creating my basic layout for my '''if''' statement, I will get to work on showing you what you can do with these.  
 
|-
 
|-
 
|00:43
 
|00:43
|Before we had example such as '1 is greater than 1' which at the moment is going to return 'false'
+
|Before we had example such as '1 is greater than 1' which at the moment is going to return '''False'''
 
|-
 
|-
 
|00:54
 
|00:54
|let's just check it to see where we are.... right . So that's "false".
+
|Let's just check it to see where we are.... right!. So that's "False".
 
|-
 
|-
 
|01:04
 
|01:04
|Now what if I said "if 1 is greater than 1 or equals 1".
+
|Now, what if I said "if 1 is greater than 1 or equals 1".
 
|-
 
|-
 
|01:18
 
|01:18
|Now we don't write it as 'or' we write it as two horizontal lines or two pipes.
+
|Now we don't write it as 'OR', we write it as two vertical lines or two pipes.
 
|-
 
|-
 
|01:26
 
|01:26
Line 31: Line 31:
 
|-
 
|-
 
|01:38
 
|01:38
|So if we compile this, what do you think the result is gonna be?  
+
|So, if we compile this, what do you think the result is gonna be?  
 
|-
 
|-
 
|01:43
 
|01:43
|Now let's run through this once - if 1 is greater than 1 - "false" and so we have written "false" or 1 is equal to 1...
+
|Now let's run through this once - '''if 1 is greater than 1''' - "false" and so we have written "false" or 1 is equal to 1...
 
|-
 
|-
 
|01:54
 
|01:54
|We know that 1 equals to 1 is "true"; so here we are saying 'or' 1 is equal to 1 not 'and' because if we said 'and' then both would have to be "true".  
+
|We know that '''1 equals to 1''' is "true". So, here we are saying '''OR''' 1 is equal to 1, not '''AND'''; because if we said '''AND''' then both would have to be "true".  
 
|-
 
|-
 
|02:09
 
|02:09
|or either of these could be "true" to make this.
+
| '''OR''', either of these could be "true" to make this.
 
|-
 
|-
 
|02:12
 
|02:12
Line 46: Line 46:
 
|-
 
|-
 
|02:16
 
|02:16
|Okay so that's the 'OR'.
+
|Okay, so that's the '''OR'''.
 
|-
 
|-
 
|02:18
 
|02:18
|Basically it allows you to take two comparisons, show them in your "if" statement and if either of them are "true" - then it's like an "either" operator...
+
|Basically it allows you to take two comparisons, show them in your '''if''' statement and if either of them is "true" - then it's like an either operator...
 
|-
 
|-
 
|02:30
 
|02:30
|"either" of them are "true", you will be left with "true".
+
|either of them are "true", you will be left with "true".
 
|-
 
|-
 
|02:34
 
|02:34
|"AND" operator is a different manner.
+
|''''AND' operator''' is a different manner.
 
|-
 
|-
 
|02:39
 
|02:39
|"and" requires both of these to be "true" for this to be executed.  
+
|'''AND''' requires both of these to be "true" for this to be executed.  
 
|-
 
|-
 
|02:46
 
|02:46
|So we have got "false" here because 1 is not greater than 1.
+
|So, we have got "false" here because 1 is not greater than 1.
 
|-
 
|-
 
|02:51
 
|02:51
|We'll go back to our comparison operators and we will say "if 1 is greater than 1 or equal to 1 'and' 1 equal 1", here we will get "true".  
+
|We'll go back to our comparison operators and we will say "if 1 is greater than 1 or equal to 1 '''AND''' (&&) 1 equal 1", here we will get "true".  
 
|-
 
|-
 
|03:04
 
|03:04
Line 70: Line 70:
 
|-
 
|-
 
|03:10
 
|03:10
|But I am pretty sure that you have got the hang of variables by now, by following my other tutorials.
+
|But I am pretty sure that you have got the hang of variables by now by following my other tutorials.
 
|-
 
|-
 
|03:17
 
|03:17
|So these are the two logical operators.
+
|So, these are the two '''logical operators'''.
 
|-
 
|-
 
|03:20
 
|03:20
|You will find them very useful because you might want to say for example - this is a very classic example. You'll find it in one of my projects....
+
|You will find them very useful because you might want to say, for example, this is a very classic example; you'll find it in one of my projects.
 
|-
 
|-
 
|03:30
 
|03:30
|It is a "login" form.  Say a user wants to login into a website.
+
|It is a "login" '''form'''.  Say, a user wants to 'login' into a website.
 
|-
 
|-
 
|03:35
 
|03:35
Line 91: Line 91:
 
|-
 
|-
 
|03:52
 
|03:52
|So we can say, for example.
+
|So, we can say, for example:
 
|-
 
|-
 
|03:54
 
|03:54
|If the username in fact let's do this. I'll say "username" is equal to "alex" and my password is equal to "abc".
+
|If the username, in fact let's do this, I'll say '$username' is equal to "alex" and my '$password' is equal to "abc".
 
|-
 
|-
 
|04:04
 
|04:04
|Now I will substitute these. I can say "username" and "password".  
+
|Now, I will substitute these. I can say "username" '''AND''' (&&) "password".  
 
|-
 
|-
 
|04:11
 
|04:11
|At the moment, this will say "true".
+
|At the moment, this will say "True".
 
|-
 
|-
 
|04:15
 
|04:15
|I'll change this.  I'll say 'ok' or 'you forgot to fill out a field' because there will eventually be HTML fields.
+
|I'll change this.  I'll say "OK" or "you forgot to fill out a field" because there will eventually be '''HTML fields'''.
 
|-
 
|-
 
|04:27
 
|04:27
Line 109: Line 109:
 
|-
 
|-
 
|04:32
 
|04:32
|So let's try it. Yes, that's saying "ok".
+
|So, let's try it. Yes, that's saying "OK".
 
|-
 
|-
 
|04:37
 
|04:37
|Now what happens if I forget to type my password in there? There's nothing in there at the moment - no space - lets get rid of that.  
+
|Now what happens if I forget to type my password in there? There's nothing in there at the moment - no space - let's get rid of that.  
 
|-
 
|-
 
|04:48
 
|04:48
|'You forgot to fill out a field'.
+
|"You forgot to fill out a field".
 
|-
 
|-
 
|04:50
 
|04:50
|So if you imagine these are coming from the user - so it has been submitted as you typed your "username" and "password" in.
+
|So, if you imagine these are coming from the user - so it has been submitted as you typed your "username" and "password" in.
 
|-
 
|-
 
|05:00
 
|05:00
Line 127: Line 127:
 
|-
 
|-
 
|05:14
 
|05:14
|We'll just check that there you go.
+
|We'll just check that, there you go.
 
|-
 
|-
 
|05:18
 
|05:18
|So because we have got "username" and "password" then that's fine.
+
|So, because we have got "username" and "password" then that's fine.
 
|-
 
|-
 
|05:23
 
|05:23
|But for the 'or' that doesn't really makes sense and you can imagine what will happen.
+
|But for the 'OR' that doesn't really make sense and you can imagine what will happen.
 
|-
 
|-
 
|05:29
 
|05:29
|So right now, this will equal "true" because we have got both values.  So this is 'ok'.
+
|So right now, this will equal "true" because we have got both values.  So this is "OK".
 
|-
 
|-
 
|05:36
 
|05:36
|Now if I go with both of them and try it out.
+
|Now, if I go with both of them and try it out.
 
|-
 
|-
 
|05:41
 
|05:41
|"if the username exists" so the username is "true"...
+
|If the username exists, so the username is "True"...
 
|-
 
|-
 
|05:45
 
|05:45
|At the moment there is no value - so it is "false".  
+
|At the moment there is no value - so it is "False".  
 
|-
 
|-
 
|05:48
 
|05:48
|"or the password is true" - that is, the value exists; at the moment it doesn't, so it is "false".  
+
|or the password is true - that is the value exists, at the moment it doesn't, so it is "False".  
 
|-
 
|-
 
|05:56
 
|05:56
|So we are going to say  "You forgot to fill out a field".
+
|So, we are going to say  "You forgot to fill out a field".
 
|-
 
|-
 
|06:00
 
|06:00
|I'll just write here nothing because at the moment it means nothing.
+
|I'll just write here "Nothing" because at the moment it means nothing.
 
|-
 
|-
 
|06:05
 
|06:05
|So refresh I'll make it nothing.  
+
|So '''refresh'''. I'll make it "Nothing".  
 
|-
 
|-
 
|06:08
 
|06:08
|So you see, already I have explained how useful these can be in so many every day php applications.
+
|So you see, already I have explained how useful these can be in so many every day '''php applications'''.
 
|-
 
|-
 
|06:17
 
|06:17
Line 169: Line 169:
 
|-
 
|-
 
|06:24
 
|06:24
|Two operators that are logical operators.
+
|Two operators that are '''logical operators'''.
 
|-
 
|-
 
|06:27
 
|06:27
Line 181: Line 181:
 
|-
 
|-
 
|06:37
 
|06:37
|This is Sidharth dubbing for the Spoken Tutorial project.
+
|This is Sidharth, dubbing for the Spoken Tutorial project.

Latest revision as of 21:02, 19 December 2018

Time Narration
00:00 Hello and welcome to a tutorial on Logical Operators. It's a very brief tutorial but I will keep it like that at the moment.
00:09 I'll use an example of an "if" statement again because that's all I have got at the moment.
00:18 What is a logical operator? Let's add a bit of logic and say it's the AND or the OR operator.
00:27 Now, if I start creating my basic layout for my if statement, I will get to work on showing you what you can do with these.
00:43 Before we had example such as '1 is greater than 1' which at the moment is going to return False
00:54 Let's just check it to see where we are.... right!. So that's "False".
01:04 Now, what if I said "if 1 is greater than 1 or equals 1".
01:18 Now we don't write it as 'OR', we write it as two vertical lines or two pipes.
01:26 Not quite sure about that but if you know my keyboard it will be next to the shift key - two vertical lines that means 'OR'.
01:38 So, if we compile this, what do you think the result is gonna be?
01:43 Now let's run through this once - if 1 is greater than 1 - "false" and so we have written "false" or 1 is equal to 1...
01:54 We know that 1 equals to 1 is "true". So, here we are saying OR 1 is equal to 1, not AND; because if we said AND then both would have to be "true".
02:09 OR, either of these could be "true" to make this.
02:12 The output. So hopefully we get "true".
02:16 Okay, so that's the OR.
02:18 Basically it allows you to take two comparisons, show them in your if statement and if either of them is "true" - then it's like an either operator...
02:30 either of them are "true", you will be left with "true".
02:34 'AND' operator is a different manner.
02:39 AND requires both of these to be "true" for this to be executed.
02:46 So, we have got "false" here because 1 is not greater than 1.
02:51 We'll go back to our comparison operators and we will say "if 1 is greater than 1 or equal to 1 AND (&&) 1 equal 1", here we will get "true".
03:04 So now, all I can really think is about to add a few variables in to this test.
03:10 But I am pretty sure that you have got the hang of variables by now by following my other tutorials.
03:17 So, these are the two logical operators.
03:20 You will find them very useful because you might want to say, for example, this is a very classic example; you'll find it in one of my projects.
03:30 It is a "login" form. Say, a user wants to 'login' into a website.
03:35 You've probably logged into a website before and it said to enter your "username" and "password". Now the keywords are in here.
03:43 We need to check if the users have entered the "username" and the "password".
03:48 If they haven't, there is no point in comparing the "username" to the "password".
03:52 So, we can say, for example:
03:54 If the username, in fact let's do this, I'll say '$username' is equal to "alex" and my '$password' is equal to "abc".
04:04 Now, I will substitute these. I can say "username" AND (&&) "password".
04:11 At the moment, this will say "True".
04:15 I'll change this. I'll say "OK" or "you forgot to fill out a field" because there will eventually be HTML fields.
04:27 This is going to be okay because we have got both values.
04:32 So, let's try it. Yes, that's saying "OK".
04:37 Now what happens if I forget to type my password in there? There's nothing in there at the moment - no space - let's get rid of that.
04:48 "You forgot to fill out a field".
04:50 So, if you imagine these are coming from the user - so it has been submitted as you typed your "username" and "password" in.
05:00 We are saying "username" and "password"; basically "username" itself is "true" because it exists...
05:07 If you had that inside, that would be acceptable; that would be "true".
05:14 We'll just check that, there you go.
05:18 So, because we have got "username" and "password" then that's fine.
05:23 But for the 'OR' that doesn't really make sense and you can imagine what will happen.
05:29 So right now, this will equal "true" because we have got both values. So this is "OK".
05:36 Now, if I go with both of them and try it out.
05:41 If the username exists, so the username is "True"...
05:45 At the moment there is no value - so it is "False".
05:48 or the password is true - that is the value exists, at the moment it doesn't, so it is "False".
05:56 So, we are going to say "You forgot to fill out a field".
06:00 I'll just write here "Nothing" because at the moment it means nothing.
06:05 So refresh. I'll make it "Nothing".
06:08 So you see, already I have explained how useful these can be in so many every day php applications.
06:17 For example - a form someone can fill in. You will find many other users for it.
06:22 But that's it then.
06:24 Two operators that are logical operators.
06:27 Just try them out and see what all you can do with them.
06:31 I will be using these most definitely in one of my projects quite soon.
06:35 Thanks for watching.
06:37 This is Sidharth, dubbing for the Spoken Tutorial project.

Contributors and Content Editors

Gaurav, Minal, Pratik kamble, Sandhya.np14