Hello, in this video we are going to cover functions inside our classes. So to create a function, you just put public and then the function name or you know, first you put the keyword function, then the function name, and I'm just going to call this print all info, they put, you know, the premises, and then the curly brace like so. In here, all I'm going to do is print out all our, you know all the variable properties and say echo speed is. So instead of doing this, all I'm going to do is call this particular function. So all I'm going to say is dollar OBJ. Then print on in focus, it's a function, e to have the parentheses at the end.
And OBJ two. Yeah, we don't really need that modifier here of just showing something in the previous video. Sorry. So if you're accessing it within the class, you need to put dollar this which just say is part of this class without the dollar there. There we go. So speed is 10 speed is 10.
Let's actually print out a new line. And what we can also do is create two more variables, public acceleration, this is 3.5. And then public wheels for the number of wheels, for By default, the number of wheels is going to be four. And what we're going to do is print out all these properties and say Acceleration is law and then number of wheels, number of wheels. Now if I run that, there we go, we have all of it printed out. And let me just quickly show you that it works if I modify one of the properties, so for the dollar OBJ for modified the acceleration, this is 20.
And if I do this again, as you can see, acceleration for vehicle one is 120. So, I'm just gonna do one little change or addition to say, vehicle one that's So I'll do something in this vehicle to start. And what I'm also going to do is at the end of each of these just echo as well. So copy that is just going to be a bit nicer formatting isn't actually required. But as you can see if you see what belongs to what now, and as you can see, it still had its own individual properties. So this is a way to create a function.
In this case, I've just literally, you know, what's it called? I lost my train of thought and then literally just print out something and it's very basic function. So if you want to learn more about functions, feel free to go to that part of the series and everything we do in functions, like returning the value Like taking in parameters and passing in values, and all that stuff we can do in a function. So long as you know, everything that we've covered in the functions part of this series, and what we've covered here, you can combine them for more advanced functions in classes. But apart from that, it's really all you need to know until the hotspot function there. And in a separate video, I'm going to cover what these keywords mean and their significance.
And is it any questions feel free to pop me a message and as usual, I look forward to seeing you in the next video.