Page 1 of 1
What Is Differences Between Objects And Classes In Php?
Posted: Wed Jun 06, 2012 6:54 am
by phpdevelopers
What Is Differences Between Objects And Classes In Php?
Re: What Is Differences Between Objects And Classes In Php?
Posted: Wed Jun 06, 2012 7:07 am
by social_experiment
A class is a piece of code containing methods and properties. An object is a new instance of the class from where you can use the methods & properties in the class.
Re: What Is Differences Between Objects And Classes In Php?
Posted: Wed Jun 06, 2012 8:02 am
by Chris Corbyn
This concept applies to all OO languages, not just PHP. A class is basically a description for what an object contains and does. To make the object (instance of the class) behave differently, you edit the code in the class.
Re: What Is Differences Between Objects And Classes In Php?
Posted: Wed Jun 06, 2012 2:05 pm
by Christopher
It is important to remember that Objects are Data + Code. Think Data first -- a Class is a custom data type. A Class contains the variable declarations for the data and the code that operates on that data. So a class defines both how to declare the object's data and what operations can be performed on the data.
An object is the actual data, so you can have many objects created from a single Class declaration.