This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Objects in PHP Forum

View Course » View Exercise

261 points
Ec924c8d68a018166fa15d25189b04f0?s=140&d=retro
Submitted by
khanmikail
about 2 years ago

Need Help with objects and Classes!

Hello!
Can Someone please make me understand on Objects and classes!I'm really confused :'(


1 vote

permalink

A class is the blueprint for building objects. Objects are then made from following what instructions are provided by the class.

Think of an object as a vehicle. Not all vehicles are the same. There are trucks, cars, motorcycles, etc. However they are all vehicles.

When you create a class for vehicles you give it different properties such as the size, number of wheels, speed, etc..

After you have created the framework for the class you can create new 'instances' of it aka an object. When you create a new instance of the vehicle class you are creating a new object. With each object you can then specify the different properties that are included in the class.

For example you may have an object representing a motorcycle with a numOfWheels field set to two. You might have another object representing a car where numOfWheels is equal to 4.

This is the most basic explanation I could give. Not sure where you are at in the lessons or if you have looked into it anywhere else. Objects will be very important so definitely make sure that you have a solid understanding of them.

572 points
5490623a76b8fe1728001bc9_369419910
Submitted by
Nick Wasik
about 2 years ago