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.

  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


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
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates


Dev Shed Tutorial Topics: