Object Oriented Programming in PHP

Jun 18, 2009 Author: Developer

Object Oriented Programming in

Object orientation is probably the area that has been subject to the most significant
and far-reaching changes with the advent of PHP 5.

Rather than making things
incompatible with previous versions of the language, however, they enhance PHP
4’s meagre OOP offerings and make PHP 5 a fully functional object-oriented language—
plus, of course, they make your life easier.

OOP Fundamentals...

While the goal of this chapter is not to provide a guide to the concepts of objectoriented
programming, it’s a good idea to take a quick look at some of the fundamentals.

OOP revolves around the concept of grouping code and data together in logical
units called classes.

This process is usually referred to as encapsulation, or information
hiding, since its goal is that of dividing an application into separate entities
whose internal components can change without altering their external interfaces.

Thus, classes are essentially a representation of a set of functions (also called methods)
and variables (called properties) designed to work together and to provide a specific
interface to the outside world. It is important to understand that classes are just blueprints that cannot be used directly—they must be instantiated into objects,
which can then interact with the rest of the application. You can think of classes as
the blueprints for building a car, while objects are, in fact, the cars themselves as
they come out of the production line. Just like a single set of blueprints can be used
to produce an arbitrary number of cars, an individual class can normally be instantiated
into an arbitrary number of objects.

views 2871
  1. Add New Comment