 Hey everybody, this is Brian, and welcome to the 43rd LAMP tutorial. Today we're going to be discussing cloning. So, what is a clone? Well, clone is an exact copy, and let's examine what we got here. We have a class called person. It has a public called name. We're making a new instance. We're setting the name to Brian, and we're just echoing it out. You can see there's my name right there. Alright, now, let's say we want to do something. So, we'll say, oh, actually just function, do something. And what we want to do here is we want to actually change this. And what do I mean by change this? Well, we're going to change the name of this. So, we're going to say bar, and we're just going to say my daughter's name, Heather. We'll do something, and then we're going to just echo it out again. Now, notice how we have our instance. We set the property. We echo it out. We then do something with that variable, and then echo it out again, and the name is changed. Well, it's because we changed the name. PHP uses what's called a by reference, which means we are not handing a copy of this object. We're handing the actual object over. So, any changes we make in this function will affect the original object. Well, sometimes we don't want that behavior. Sometimes we want to, I don't know, predict the future or do something without affecting the original object. So, what we need to do here is call B, clone, and we're just going to say bar. So, we're going to make a clone of this object, and then work with the clone. You see how now when we run it, we do everything as before. Echo it out. There's a name. Do something. We're making a clone. We're working with the clone right here, and then we echo it back out, and the original object is still the same. So, let's just echo this just to see. So, as you can see now, there's the original, and then Heather is the clone's name, which because she's my daughter, that's actually pretty appropriate, and then there's our original object again. So, that is the foundation of cloning. We're taking this original object and making an exact copy of it in memory. That way we can manipulate the object without affecting the original. Pretty simple, pretty easy to understand, but it's one of those gotchas where people will make a function pass a variable to it. They don't realize they're passing it by reference. They change a bunch of things, and then they get all the changes back when they didn't want them. So, that's all for this tutorial. I hope you found it educational and entertaining, and thank you for watching.