O'Reilly logo

Object-Oriented Programming with PHP5 by Hasin Hayder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Kick-Starting OOP

In this chapter we will learn how to create objects, define their attributes (or properties) and methods. Objects in PHP are always created using a "class" keyword. In this chapter we will learn the details of classes, properties, and methods. We will also learn the scope of methods and about modifiers and the benefits of using interfaces This chapter will also introduce us to other basic OOP features in PHP. As a whole, this chapter is one of the better resources for you to kick-start OOP in PHP.

Let's Bake Some Objects

As I said before, you can create an object in PHP using the class keyword. A class consists of some properties and methods, either public or private. Let's take the Emailer class that we have seen in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required