note 86817 deleted from language.oop5 by aharvey
| From: | aharvey@php.net | Date: | Wed, 27 May 2009 02:08:18 +0000 |
| Subject: | note 86817 deleted from language.oop5 by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156046@lists.php.net to get a copy of this message | ||
Note Submitter: secure_admin
----
CREATE NEW TYPES OF OBJECTS
The PHP Core Language provides objects of type [String], [Number], [Array], etc and makes them
available to every script you write automatically. BUT, when you need objects of a more specialized
nature (for portability, extendability, maintainability, whatever the reason), you can create them
easily by writing a PHP Class Definition - which literally creates new "types" of objects
for you on-the-spot.
<?php
class Customer {
// define an object of "type" [Customer].
}
class Item {
// define an object of "type" [Item].
}
class ShoppingCart {
// define an object of "type" [ShoppingCart].
}
?>
Now, assuming the "class defs" above have been filled-in to your satisfaction, included,
imported, and/or loaded into our script somehow, we'll now have these "types of
objects" to work with:
[String] - provided by PHP automatically
[Number] - provided by PHP automatically
[Array] - provided by PHP automatically
[Customer] - defined above
[Item] - defined above
[ShoppingCart] - defined above
As you can see, we now have six(6) types of objects to work with, verses the three(3) we would have
normally been stuck with.