I will.
Going back again to another video lecture in PHP.
And in this video lecture we go ahead and look at classes in PHP.
So PHP is an object oriented programming language.
So we are going to learn about classes.
So classes is just a blueprint.
It can be called a specification for a custom data type.
So what I mean is that in PHP you can able to create some data types like integer data types, strings
data types and boring data types.
Then these alphabets and these are numbers.
And there are two of those for Boolean and so on.
But there are some things we want to be able to represent like a objects something like your yourself
car book, laptop and foams and you'll be like, how do we represent this?
So that is where classes come in.
It enables us to create our own custom data type.
So once we are talking about classes, we are trying to create your own custom data types because we
have that ability to create normal data types like integers, uh, strings, booleans and so on.
So we can create our own custom data types because we can't represent everything in variables like string
numbers or booleans.
So and by creating our own custom data types we are creating uh classes.
So class is a specification of a custom data type.
And we can use that to model anything we want to do.
Now let me go ahead and uh, let us do this with a practical example.
Let me go ahead and say I want to create a class of a car, and then this class of a car is a blueprint
about a car, and the editor module creates a class of anything.
You are going to break that down into variables of, uh, let me say I'm going to break that down into
attributes.
Now, if I want to break down cars or the attributes of a car, like the year the car was made, the
color of the car, the manufacturing and the name of the car.
So we go ahead and, uh, create a curly brace.
And here I'm going to break down the attributes of this car.
So if I want to break that down I'll put them into variables.
So I'm going to say var and then I'm going to actually put in.
Let me say the first one is the name of the car.
Right.
So And, uh, let me see.
The next one I want is the year of the car.
Then the next one is the color of the car.
Now, these are the blueprints or the attributes of this car.
So the class is the blueprint and the whatever it is in there is the actual bus and the the actual bus
is what we are going to use.
We have not created the real object.
Now we have gotten the actual bus.
What we need to do now is to go ahead and create an object of this car.
So the object of the car is known as the instance of the class.
So the object we are creating is not at the instance of that class, the actual car which we are going
to model and which the objects are going to create.
Now let's go ahead and create that.
I'll go ahead and say create this variable called car and let me call out to be car one, because we
might be dealing with more or different cars and they're their guidance.
See?
New car.
Now we have a new car, kind of with a semicolon.
Now this, which we created right in here.
The new car is the object of this car, which is the instance of the actual class.
So now let's go ahead and specify the this attributes which we just created over here.
So here is where I'm going to give in the name of the car the year and the color.
So I'm going to say car one then.
And for me to give the first one is the name I'm going to say car one name.
Then the name of this car is going to say this is a Toyota.
So you can model anything right in here.
Then the next one is it's going to gonna see.
The next one is to one.
Is the year.
And let this year be equal to.
We have our 20.
2030 model.
Right.
So depending on the time you're taking this it might have come out by then.
Then the next one is a the next attribute we have like right in there is a color.
Then let the color be equal to black.
So let's use a color that is a universal.
Now you can go ahead and print out these.
We have created the object of this car which is this which we have right here, the new car okay.
Now what we need to do now is we go ahead and print out these.
For me to do that, to go ahead and say echo.
And there are Korhonen.
See?
Go ahead and say car one.
And then you print out any of the attributes which you want to print out.
Maybe if it is, the name can go ahead and say the name and a semicolon at the end.
And if I refresh this we have Toyota.
You can see that now if you want to print out the year it's going to say the year.
And then go ahead and save this and print this out 2030.
If you are dealing with the color you can go ahead and say color.
And then that is black.
Now you can create so many of these objects of this car.
Now you can go ahead and create a car too.
Let's go ahead and see that car two is equal to new.
New car.
So K2 is equal to a new car with a semicolon at the end.
And then we go ahead and copy everything we have here so we can just, uh, just say, uh, edit that.
Now go ahead and change this to .2.2.
All right.
So change this as well to dot two and change this to cart two.
So I mean the next car should be like uh named as Nissan.
Then maybe this is a in the year 2070 and then color the equal to white.
Now let's go ahead and save this.
So for us to do that just go ahead and say equal to or sorry this is car two.
And if we check the color check out and that is white.
So in this way you can be able to create your own custom data type.
And there you go ahead and model it by creating a class, creating an object which is the instance of
the class.
And then we can be able to break or use the attributes to do whatever you want.
So I want to look more into the classes and the the object oriented programming as you move into this
class.
So for had I checked out this and know that the classes are custom data types which you create and the
objects are instance of the class which you create, which is the abstract car which you are creating
here.
So you can model anything you want right in here.
And then you go ahead and check it out.
So play around with it.
And if you have any questions under this use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.