Ajax-loader-large-white
Objects in PHP
Objects in Real Life

How object-oriented programming is used in real life can be shown with a forum as an example:

Every forum user (object) has the same rights: he can log in and write (methods), can contain some settings (properties), but every user has a different name (another property).

Every user is created easily, as you create a new instance of a User class when you sign up. And as we've seen, there are some properties and methods that every instance has in common (such as logging in and writing), and there are some which are unique (such as each user's name).

And without object-oriented programming—OOP for short—this could not be done that easily. ;-)

Another example: on the right, there is a Person class, so every new Person has some properties, like $isAlive or $firstname, and a method greet().

Right now there is only one instance of the Person class: $me. But we'll reconstruct this class and you'll even create another instance of the class, so your name will be echod, too.

In the next exercises we are going to create some classes, so let's start coding. :-)

Instructions

Everything crystal clear? Good, press Save & Submit Code.

index.php
style.css
project
View Preview