Home arrow PHP arrow Page 3 - Back To Class

If Wishes Were Prancing Horses... - PHP

Classes and objects are powerful OOP concepts - and PHP4 supportsthem too. This article explains some basic OO entities (including classes,constructors and extensibility) with examples of a table builder and aguestbook.

TABLE OF CONTENTS:
  1. Back To Class
  2. Who Needs Class, Anyway?
  3. If Wishes Were Prancing Horses...
  4. New Cars For Old
  5. Ford's Law
  6. Turning The Tables
  7. Under Construction
  8. Extending Yourself
  9. Be My Guest
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 9
October 05, 2000

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Given the class, it's now simple to spawn as many Automobiles as you like, and adjust the individual properties of each. Take a look:

<? // let's spawn a couple of cars // this is mine... $his = new Automobile; $his->make = "Ferrari"; $his->colour = "Black"; $his->shape = "Cigar"; // ...and this is yours $hers = new Automobile; $hers->make = "Porsche"; $hers->colour = "Silver"; $hers->shape = "Torpedo"; // hey...i can dream, can't i // i feel like taking mine out for a spin $his->start(); // speed limit? you must be joking! $his->accelerate(180); // joining me, are you? $hers->start(); $hers->accelerate(150); // oops...was that a speed trap? $his->decelerate(80); $hers->decelerate(80); // busted! $his->stop(); $hers->stop(); ?>
As the illustration above shows, once new objects are defined, their individual methods and variables can be accessed and modified independent of each other. This comes in very handy, as the next few pages will show.

 
 
>>> More PHP Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap

Dev Shed Tutorial Topics: