WEBVTT

00:00.500 --> 00:03.320
I will carry you back again to another video lecture in PHP.

00:03.470 --> 00:09.140
And in this video lecture I warhead and tissue about object functions in PHP.

00:16.070 --> 00:16.550
All right.

00:16.550 --> 00:19.400
So in PHP we have what's called object functions.

00:19.400 --> 00:24.860
And these are functions that are used by objects to perform some specific tasks.

00:25.250 --> 00:28.430
In PHP now we have this value function which we create.

00:28.430 --> 00:30.170
Here is a constructor function.

00:30.170 --> 00:33.590
And the object function is go ahead and go down here.

00:33.590 --> 00:39.200
So we have learnt about classes and objects and we have done something num constructions.

00:39.230 --> 00:41.300
Then let's go ahead and look at object functions.

00:41.300 --> 00:44.210
So go right in here and create a function.

00:44.210 --> 00:51.290
And what is this function to determine about this car here to know a car is updated.

00:51.290 --> 00:59.090
So any car that is above 2 or 2000 or which is updated above 2000 is still current, but any car that

00:59.120 --> 01:01.710
is characters below 2000 is outdated.

01:01.710 --> 01:07.050
So I will first of all change the genes in the son to be like a 1997 model.

01:07.050 --> 01:12.420
So if you are driving 1997 model, that means you are driving an outdated car.

01:12.840 --> 01:17.160
All right, so this function, we have to determine which of the cars that is outdated.

01:17.280 --> 01:21.000
If it is updated it's going to be true or false.

01:21.000 --> 01:23.670
Let's go ahead and determine that it's here.

01:23.700 --> 01:24.810
This function is done.

01:24.810 --> 01:27.060
Go ahead and say outdated.

01:27.810 --> 01:34.170
So it does try to use this function to check the current cars and the the the test cars.

01:34.200 --> 01:36.810
That is the aim of this program.

01:36.840 --> 01:45.870
Now let's go ahead and create this function because we have to learn how to use this functions to work

01:45.870 --> 01:46.950
with our objects.

01:46.950 --> 01:52.320
That's why object functions are very important to learn, because it doesn't stop in creating constructors

01:52.320 --> 01:53.340
and classes.

01:53.340 --> 01:56.100
You also going to add some things and use that.

01:56.100 --> 01:57.910
So the more you create more functions.

01:57.910 --> 01:59.290
Here you're creating objects.

01:59.590 --> 02:00.430
Functions.

02:00.460 --> 02:03.700
Now let's go ahead and see if.

02:04.240 --> 02:10.420
And then you go ahead and specify the current object you're talking about.

02:10.420 --> 02:11.710
So if this.

02:11.710 --> 02:14.350
So let me go ahead and remove one of these.

02:14.350 --> 02:19.990
So if this and we're going to use the E the variable we're going to talk about is the e.

02:19.990 --> 02:31.540
So if this year and that is very important it's a equal or that is greater than or equal to then go

02:31.540 --> 02:34.210
ahead and shift this because everything is together.

02:34.240 --> 02:37.060
Now let's go ahead and say is equal to 2000.

02:37.060 --> 02:39.670
So any one of these are from 2000 and above.

02:39.700 --> 02:41.890
That's why I included 2000 okay.

02:41.890 --> 02:52.720
So if this is the year is greater than or equal to 2000 then is correct and return false.

02:52.720 --> 03:03.140
So that's any correct is above 2000 is not updated, but if the car is a below 2000, it will go above

03:03.140 --> 03:05.270
and I go ahead and return.

03:05.480 --> 03:10.280
True because we are more interested in outdated and not outdated.

03:10.310 --> 03:19.070
Now if we go ahead and use this return false and a true this abhorrence and there might be an error

03:19.100 --> 03:25.550
because sometimes the boolean you would return false when it is true.

03:25.550 --> 03:27.050
So let's go ahead and make this.

03:27.050 --> 03:28.070
So don't confuse.

03:28.070 --> 03:30.920
And let's go ahead and make this to be string.

03:30.950 --> 03:37.460
Let's go ahead I use string here instead of using the uh the boolean just the way it is.

03:37.490 --> 03:39.050
Go ahead and set true.

03:39.560 --> 03:41.270
Now let's go ahead and save this.

03:41.270 --> 03:50.150
And uh, if we go ahead and go over here and go down to eco, we want to check which of these is, uh,

03:51.140 --> 03:54.240
outdated and war that is not US debt.

03:54.270 --> 03:59.790
Now go ahead and replace the E with the function name outdated.

03:59.790 --> 04:03.180
So we're calling the function outdated now.

04:03.210 --> 04:05.910
And let's go ahead and refresh this and check this out.

04:05.940 --> 04:10.620
And it says unexpected token in line 21.

04:10.620 --> 04:13.500
So that is what we have right here.

04:13.500 --> 04:15.060
So go ahead and put this back.

04:15.090 --> 04:16.710
This is a greater than or equal.

04:16.740 --> 04:17.910
This is what it's supposed to be.

04:17.940 --> 04:20.430
Go ahead and save this and check it out.

04:20.430 --> 04:25.350
So with the one we are checking is false because Q1 is 2030.

04:25.350 --> 04:27.810
So that is still a current car.

04:27.810 --> 04:34.470
And if we go ahead and change this to car two and change this to Cat two and go ahead and refresh this,

04:34.500 --> 04:39.180
you can see that is true because Q2 is 1997.

04:39.180 --> 04:45.000
So we need to go ahead and change this car two to like a 2051 and save.

04:45.000 --> 04:45.840
These are the fresh.

04:45.870 --> 04:46.590
Let's check it out.

04:46.590 --> 04:47.580
That is false.

04:47.580 --> 04:48.600
So you can see that.

04:48.630 --> 04:57.160
So object function helps us to be able to add some functions into our classes and it will help us to,

04:57.580 --> 05:01.240
you know, to implement some specific tasks on the object.

05:01.240 --> 05:03.760
And you can see that I created this function once.

05:03.760 --> 05:06.700
And where would two use that on both of these.

05:06.700 --> 05:13.210
Because whenever you create a function inside here it's a it's going to be implemented into the object

05:13.210 --> 05:14.110
of that class.

05:14.110 --> 05:17.260
Because both of these objects are the objects of the class.

05:17.260 --> 05:21.430
Cutter, you understand, is both of the object and the object of the class car.

05:21.460 --> 05:26.320
So if we create more and more of this object, and eventually you create your application to add objects

05:26.320 --> 05:28.780
of that particular class you're working with.

05:28.780 --> 05:34.600
So and now anytime you check true or false, either one of them, it will go ahead and give you the

05:34.600 --> 05:35.170
output.

05:35.170 --> 05:39.220
So this is about construct a object functions in PHP.

05:39.250 --> 05:41.530
Go ahead and check more on that.

05:41.530 --> 05:44.980
And if you have any question go ahead and use the question and answer section.

05:44.980 --> 05:47.560
And I'm going to get back to you as soon as possible.

05:47.590 --> 05:48.460
Thank you so much.

05:48.490 --> 05:51.310
And I'm going to see you in the next video lecture.
