PHP Using PHP with MySQL Connecting PHP to MySQL Introducing Classes

what is the deference between class and object ? google traduction Didn't help me on that :v and thanks

i didn't understand when he said "php mailer object is instantiate a class mailer" ?

2 Answers

William J. Terrell
William J. Terrell
17,403 Points

That particular video confused me as well. From the transcript, though, I've pulled the following:

"An object is a complex variable type that bundles other variables and functions together into a single unit. Those variables are called "properties" of the object and those functions are called "methods" of the object."

Which, if we break it down:

1.) an Object is a Variable 2.) an Object bundles other variables and functions into a Singularity 3.) The variables that get bundled are then called Properties 4.) the functions that get bundled are then called Methods

Then there was this bit:

"In PHP, a class is a type of object, or an object definition. The class defines what properties and methods will exist inside any objects of that class. Each object is said to instantiate its class, which means it is a real instance made from that class."

Which, if we break it down:

1.) A Class is what you use to define an Object 2.) A Class is what you use to define which Properties and Methods are defined in that Object.

So, what I think that means is that, you can use a Class to define variations of Objects.

For example, if you had an Object called "Cat", you could use one Class to define one instance of Cat as having a Property of "Black Fur", and another Class to define another instance of Cat as having a Property of "White Fur".

You could also use Classes to define Methods (functions) on each instance of "Cat". So you could use the Class that says "This instance of 'Cat' has 'Black Fur'" to also say "The 'Cat' with 'Black Fur' 'eats Dry Food'." (where 'Black Fur' is the Property and 'eat Dry Food' is the Method). You could use another Class that says "The 'Cat' with 'White Fur' 'eats Wet Food'." (where 'White Fur' is the Property and 'eats Wet Food' is the Method).

At least I think that is what is going on here... I apologize if I am just over-complicating things ^^;

Thanks .. You help me bro and ur comment was completly true

William J. Terrell
William J. Terrell
17,403 Points

Glad I could help :) Writing about it that way helped me to understand it a little better too :)

Tom Cawthorn
Tom Cawthorn
22,981 Points

Hmmm, that's quite a tricky one to explain easily. You create an object from a class. A class is like a blueprint for a house, and when you say 'new House' you're building a new house from the blueprints.

If you haven't already watched it, maybe this course might help you understand it better :)

Thanks ur Comment Help me alot ♥ i undesrand it :)