 Hey everybody, this is Brian. Welcome to the 30 first lamp tutorial if you've been following along we left off with the error with PHP error handling which is all fine and dandy, but It just seems to be lacking compared to other languages. So We could go into PHP exemptions, but there's a little caveat here We have to learn object-oriented programming. You see this little chuck of code throw new exemption What does that mean? Well in order to actually get to this tutorial W3Schools is actually skipped an entire section called object-oriented programming. So that's what we're going to be covering quick flip into the PHP manual here And you see that starting with PHP 5 the object model was rewritten to allow better performance and more features This was a major change from PHP 4. PHP 5 has full object model What in the world are they talking about objects and models and all this other stuff? Well, basically We've been doing procedural programming meaning you write some code and it just goes straight down like a procedure Object-oriented programming is you create objects and then those objects you can interact with and those objects can interact with other objects Etc. Etc. So the coming tutorials we're going to talk about you guessed it object-oriented programming using PHP 5 Let's go into the basics here The simplest way to explain object-oriented programming is you have to have a class. Now, what is a class? You're gonna see this a lot in the coming tutorials But a class is just a blueprint and we're not gonna actually write any code in this tutorial. I'm just talking here This is just theory the boring lecture part that nobody likes, but you got to understand this stuff So a class is a blueprint An object is an instance of that blueprint. Now, let me explain it a little differently here Let's say a class is A blueprint like a cat. Okay, just a generic cat could be your cat could be my cat could be anything It's just you look up in the dictionary cat. That's a class an Object would be my cat or your cat in other words It's a specific instance of that class that blueprint a better way of putting it And this is kind of how it really stuck with me about 20 some odd years ago is a Think of a class as a blueprint for a house an Object is the actual house, you know once the house is built, but the class is just the blueprint now You kind of understand here. So why do we create objects? Well, it's called encapsulation basically, you can create a class and Then put things in the class. You can see the structure here class name of the class It's called simple class and then public we haven't discussed this yet And there's a variable name and then the value and then a function inside of this But that's just normal PHP code a Lot of this may look foreign to you and like I said, we're going to be covering all of this so don't worry But you can see how you have multiple classes this class a class B and then you can do things with them so you have a The variable a unless you're from Canada than it's a Equals new meaning you're creating an instance. This is the difference here. This is a class a blueprint new instance of that class Technically, it's reversed. This is your variable. So that would be the instance and this would be the Class or the blueprint. So think of it this way object blueprint once you have an instance, then you can go ahead and do things for example The a variable and then we got this arrow here and then we're calling foo. What is foo? Well foo is a function inside of the class. I Know it sounds a little confusing and we're going to go over some very simple examples in the next tutorial But really all you need to understand at this point is the difference between a class and an object Because I see people even out in the real world making good money that don't understand the difference between class and an object Just remembering class is a blueprint and object is an instance of that blueprint. That's all for this tutorial I know it was rather short but very important that you understand that concept and we're going to really dive real deep into this We're going to learn object-oriented programming inside now. All right Look forward to seeing the next one