Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 2: Overview of Classes, Objects,... > Understanding Basic Concepts

Understanding Basic Concepts

If you have never done any object-oriented programming before, then the terms class and object may sound mysterious and even a bit scary. (If you have, then you can safely gloss over or even skip the next few paragraphs and proceed to recipe 2-1.) However, classes and objects are really neither mysterious nor scary. After you have used them a few times, you will start to wonder how you managed to get along without them. Once you understand how they work, you should not have any trouble creating your own.

An object is basically a type of data that allows you to group data and functions under a single variable. In PHP, the -> operator denotes a member of a specific object, that is, a property (piece of data) or method (function) belonging to an object. You can think of it as meaning "has a," with the arrow pointing from the thing doing the having to the thing being had. In PHP 5, as in previous versions of the language, it is possible to create simple objects by doing nothing more than assigning object properties to an otherwise unused variable. For example:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint