WEBVTT

00:00.590 --> 00:04.040
I will call you back again to another video lecture in PHP.

00:04.370 --> 00:09.380
In this video lecture we go ahead and look at the variables in PHP.

00:16.160 --> 00:21.650
So right on my screen I have a little story I just made for us.

00:21.650 --> 00:30.260
And this says once upon a time in the land of Alaska, there was a man named Peter who is 80 years old.

00:30.620 --> 00:33.590
Peter lived in Alaska for 80 years.

00:33.620 --> 00:38.630
One day Peter left Alaska and never returned again.

00:38.810 --> 00:44.270
So this is a piece of story, a formalized story that we have right in here.

00:44.300 --> 00:49.730
So this can be a novel, maybe up to 100 pages, 200 or 300 pages.

00:49.730 --> 00:59.210
And in that novel, you might have a Alaska name like up to 100 times, and you have the name Peter

00:59.210 --> 01:07.190
Are occurring about 200 times, and these may occur as many times as possible.

01:07.220 --> 01:11.360
Then, if we go ahead and run this graph, let's go ahead and save.

01:11.360 --> 01:12.650
These are the.

01:12.680 --> 01:13.460
Check it out.

01:13.460 --> 01:14.930
So it says on a.

01:15.260 --> 01:21.140
Once upon a time in the land of Alaska, there was a man named Peter who is 80 years.

01:21.170 --> 01:21.770
All right.

01:21.770 --> 01:22.820
I think this is so big.

01:22.850 --> 01:24.350
I'll go ahead and I'll reduce this.

01:24.350 --> 01:27.230
And now everything is now alright.

01:27.230 --> 01:33.080
So once upon a time, in the land of Alaska, there was a man named Peter who is 80 years old.

01:33.260 --> 01:35.510
Peter lived in Alaska for 80 years.

01:35.540 --> 01:38.960
One day Peter left Alaska and never returned again.

01:38.960 --> 01:43.580
So you can see in this story I can do to change anything.

01:43.730 --> 01:51.890
Let me say I'm the editor who is editing this book, and I want to change the name Alaska to maybe anything.

01:51.920 --> 01:55.010
Maybe I can name that to be, or here or any other thing.

01:55.010 --> 01:59.260
So I'll go ahead and start changing this one by one.

01:59.260 --> 02:00.820
So I'll go right in here.

02:00.850 --> 02:03.760
I change this and I come over here.

02:04.030 --> 02:06.820
I change this as well.

02:07.630 --> 02:10.090
Then the next place is the last one.

02:10.120 --> 02:11.530
I will change this again.

02:11.530 --> 02:16.960
So if I go ahead and save this or run this code, you can see that Alaska has been changed.

02:16.960 --> 02:19.270
And now we have Ohio right in here.

02:19.510 --> 02:25.630
So the state has changed from this to once upon a time in the land of oo.

02:25.660 --> 02:30.190
That was a man named Paul and no longer Peter, who is 80 years old.

02:30.310 --> 02:32.950
Paul lived in Ohio for 80 years.

02:32.980 --> 02:36.160
One day Paul left Ohio and never returned again.

02:36.160 --> 02:38.410
Maybe Paul is dead or Paul has relocated.

02:38.440 --> 02:39.760
What is 80 years?

02:39.760 --> 02:41.410
So this is just a story.

02:41.410 --> 02:45.370
And you can see I am changing the names one by one.

02:45.370 --> 02:49.540
So this is easier for if four lines of code I can actually do that.

02:49.570 --> 02:53.770
Or what if this is a whole novel and you want to do this?

02:53.770 --> 02:58.030
So how do you start changing this one by one without making a mistake.

02:58.060 --> 03:03.520
There must be a time, or you might miss some steps, or you might miss on names.

03:03.520 --> 03:07.270
Or you might write something that is not just what is supposed to be.

03:07.300 --> 03:09.130
Maybe there is a typo somewhere.

03:09.130 --> 03:11.020
So how can you be able to do this?

03:11.050 --> 03:15.280
You know, how can you change this with just a line of code?

03:15.760 --> 03:18.850
So let me go ahead and introduce us to what variables are.

03:18.880 --> 03:27.910
So variables are a containers that contain a particular piece or a word that you want to use any place

03:27.940 --> 03:29.080
in your code.

03:29.110 --> 03:38.170
So anytime you want to change a son, a name or a number or a decimal number or an integer variable,

03:38.200 --> 03:41.200
anything, you can actually use variable to do that.

03:41.200 --> 03:45.490
Now I'll go ahead and show us how to do that because it's just a container.

03:45.490 --> 03:48.880
And now it's actually learn by doing so.

03:48.910 --> 03:58.720
In order to write a variable in Python what we need to do is we go ahead and use the dollar sign.

03:58.750 --> 04:05.830
So this dollar sign is what is going to help us to be able to declare a variable.

04:05.860 --> 04:08.860
So once you create a name or that symbol.

04:08.890 --> 04:13.300
Dollar sign, it means that the next thing that comes is a variable.

04:13.330 --> 04:14.800
Now let's go ahead and see.

04:14.950 --> 04:17.950
This is a story.

04:17.980 --> 04:19.480
Now we call the story.

04:19.510 --> 04:22.810
Town is a town where you want to change.

04:22.810 --> 04:23.410
Let me see.

04:23.440 --> 04:28.060
I want to name this town, um, or camcorder to be.

04:29.260 --> 04:33.850
Um, let me call that to be any name town.

04:34.690 --> 04:37.840
So the town name is now Newton.

04:37.840 --> 04:41.680
And I can also go ahead and change the name.

04:41.800 --> 04:46.870
Now, how do I change the story name?

04:46.900 --> 04:48.280
Let me call out to the story name.

04:48.280 --> 04:49.450
You can call it anything.

04:49.450 --> 04:55.510
It's just a variable is a container that holds, um, a piece of information which can be able to use

04:55.510 --> 04:56.410
any place.

04:56.440 --> 04:56.830
All right.

04:56.860 --> 05:01.930
So I name the first one the town story town, the name I call it to be story.

05:02.110 --> 05:02.890
You can name it.

05:02.920 --> 05:04.720
You can give it any name you want.

05:04.750 --> 05:05.140
All right.

05:05.170 --> 05:06.310
It mustn't be story name.

05:06.340 --> 05:10.600
Now I'm going to change that to be the record out to be George.

05:10.630 --> 05:17.230
Then I will go ahead and give the last one to reach.

05:17.260 --> 05:17.800
All right.

05:17.800 --> 05:22.870
So I can change the age to be 95.

05:22.900 --> 05:23.230
All right.

05:23.260 --> 05:24.580
Put a semicolon at the end.

05:24.610 --> 05:32.950
Now, you can see that when I was giving this, I call this I give a this inside a quotation mark.

05:32.950 --> 05:34.330
Because this is a string.

05:34.330 --> 05:39.640
We have not discussed strings and we have not talked anything about integers and strings.

05:39.640 --> 05:40.870
But this is a string.

05:40.870 --> 05:44.320
That is why it is inside a double quotation mark.

05:44.320 --> 05:46.540
So what does an integer.

05:46.570 --> 05:47.860
You don't need that.

05:47.890 --> 05:49.720
You just leave it the way it is.

05:49.750 --> 05:51.940
Okay, now let's go ahead and save this.

05:52.240 --> 06:02.130
So the next thing I have to do is I'll go to Ohio and I'm going to change this to story and let me see.

06:04.440 --> 06:06.000
Story town.

06:08.880 --> 06:09.360
All right.

06:09.390 --> 06:11.280
So story town, let me go ahead and save this.

06:11.280 --> 06:13.170
And we're going to run this code and check it out.

06:13.200 --> 06:19.590
Now you can see once upon a time in the land of Luton and no longer Ohio, what happens?

06:20.310 --> 06:27.510
Even though I did add a little right in here, what actually happens is that the variable name has been

06:27.510 --> 06:31.770
stored inside this variable container named Story Town.

06:31.770 --> 06:37.620
And any time or any place you see Story Town, what is going to be there is Luton.

06:37.620 --> 06:46.890
So if you change this Luton to anything, let me say if you call out to be Manchester, so let's call

06:46.890 --> 06:49.770
it out to be Manchester and let's go ahead and run.

06:49.770 --> 06:54.240
This is considered in the land of Manchester so it can actually change.

06:54.240 --> 06:57.450
So it's just a container that is holding a piece of information.

06:57.450 --> 07:00.840
So whatever you put inside there is what is going to be displayed.

07:00.870 --> 07:03.780
Now I'll go ahead and copy this.

07:03.810 --> 07:05.130
Let's go ahead and copy this.

07:05.370 --> 07:07.350
And then we go over here.

07:07.350 --> 07:12.690
Any place you see or hear we change that with this variable name.

07:12.690 --> 07:17.040
And I'll go ahead and change this as well.

07:17.640 --> 07:19.440
So go ahead and change this as well.

07:20.970 --> 07:22.260
Are we okay.

07:22.290 --> 07:23.790
I actually copied that.

07:23.820 --> 07:25.440
Let me go ahead and copy this again.

07:25.980 --> 07:26.460
All right.

07:26.460 --> 07:28.380
So I'll go ahead and paste this here.

07:28.380 --> 07:33.360
And then the story name is the name of the individual.

07:33.360 --> 07:38.460
So change this to story Name and change this to Store name.

07:38.460 --> 07:45.420
And wherever we see both with the story and then the Stone age, we got it on copyright.

07:46.470 --> 07:50.370
So let's go back to Etsy and we change this.

07:50.400 --> 07:52.740
and we also change this.

07:52.770 --> 07:56.610
Now we can actually save this and then go back.

07:56.760 --> 07:58.860
Go back here and run this code and check it out.

07:58.890 --> 08:06.270
So once upon a time in the land of Manchester, there was a man named George who is 95 years old.

08:06.300 --> 08:09.870
George lived in Manchester for 95 years.

08:09.900 --> 08:14.880
One day George left Manchester and never returned again.

08:14.910 --> 08:18.660
So you can see that we are able to change everything right in here.

08:18.660 --> 08:27.840
So if this story is like up to, um, 100 lines of code, we can actually go back here and go back to

08:27.870 --> 08:31.560
here and say Manchester, go back to Alaska.

08:33.630 --> 08:35.970
Let's go back to Alaska.

08:35.970 --> 08:43.020
And, uh, the name go back to Peter and the age go back to 80.

08:43.050 --> 08:46.050
Let's save this and run this code again.

08:46.050 --> 08:51.920
So once upon a time, in the land of Alaska, there That was a man named Peter who is 80 years old.

08:51.950 --> 08:54.020
Peter lived in Alaska for 80 years.

08:54.050 --> 08:56.540
One day, Peter left Alaska and never returned again.

08:56.540 --> 09:03.470
So we can see that we were able to use variables to be able to do all this without going back right

09:03.470 --> 09:06.620
inside the stories to modify that one by one.

09:06.650 --> 09:09.320
So that is one cool effect.

09:09.320 --> 09:11.690
And one thing good about PHP.

09:11.690 --> 09:17.330
So PHP actually knows when you are using a variable and it will automatically obey that.

09:17.360 --> 09:21.740
Okay, so whatever it is inside the variable, it actually gives you back to you.

09:21.740 --> 09:26.720
Because variable is just a container that we use to hold some piece of information.

09:27.230 --> 09:28.310
So that is cool.

09:28.340 --> 09:28.670
All right.

09:28.700 --> 09:31.880
So go ahead and practice with this.

09:31.910 --> 09:32.510
Check it out.

09:32.510 --> 09:35.600
And if you have any questions on anywhere it just let me know.

09:35.600 --> 09:37.730
And I'm going to get back to you as soon as possible.

09:37.760 --> 09:38.180
All right.

09:38.180 --> 09:39.710
So I want us to move together.

09:39.710 --> 09:44.630
And for any reason you have any problem, please don't forget to use the question and answer section.

09:44.630 --> 09:46.160
And I'm always going to get back to you.

09:46.160 --> 09:48.800
So thank you and see you in the next video lecture.
