Tag Archives: object

The string object is another object built in by JavaScript. Whenever you create a string, JavaScript will automatically give it the properties and methods of a string. To clarify a few things, you can sometimes access an object directly without having to create a variable. We saw how to do this with the number object, but with the string object …

So we’ve talked about objects in general and we discovered a new object called the document object. JavaScript comes with built in objects that you can use. In this tutorial, we take a look at the number object. Number Object Properties Just like other objects, you can access the properties and methods of the number object. Let’s take a look …

This is the final tutorial. You now have a basic grasp on what object oriented programming is and how you can apply it to PHP. There’s more to it such as design. If you would like more information, then go here .http://php.net/manual/en/language.oop5.php One question, that I’ve been avoiding during this whole series is why use object oriented programming? Why use …

Polymorphism is a pretty big word, but it’s actually a simple concept to understand. Here’s how it’s officially defined. Polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. That may seem a little bit confusing to most of you new programmers. Luckily, polymorphism is a light switch concept meaning once you understand …

In some cases, you’ll find yourself needing more information passed into your methods. What if you wanted to pass in objects into your methods? This is actually possible with type hinting. Let’s learn how to do this and why it would be useful. Before we begin, we’re going to create a new class called Apple. Create a file called apple.class.php …

It’s time to make our Pet class a little more interactive. We can make our pets walk and rest. Our pet can do a chain of events. Using chain methods makes running multiple methods at once cleaner and more efficient. Let’s learn how to use chain methods. In our Pet class, add this bit of code. [crayon-5ce9602144dc1382572762/] We’re using a …

PHP provides some magic methods that run when an event occurs. You’ve already seen an example of a magic method with the __construct() method. This method runs when a user creates an instance of the Pet class. Let’s take a look at some of the other magic methods we can use in our classes. Using Magic Methods In your pet.class.php …

In this tutorial, you’ll learn how to create interfaces and why you should use them. They are very similar to abstract classes. At the end of this tutorial, we’ll discuss the differences and the benefits of each one. We’ll be creating something similar to our recipe and cookie class in our abstraction tutorial. Creating Interfaces Create a file called index.php …