Programming Basics

  Home arrow Programming Basics arrow Page 2 - Beginning Object Oriented Programming ...
PROGRAMMING BASICS

Beginning Object Oriented Programming in PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 241
    2003-11-11

    Table of Contents:
  • Beginning Object Oriented Programming in PHP
  • Objects - The Magic Box
  • Classes
  • Methods
  • Extends
  • Conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Beginning Object Oriented Programming in PHP - Objects - The Magic Box


    (Page 2 of 6 )

    Imagine a box. It can be any type of box you want: a small jewelry box, a large crate, wooden, plastic, tall and thin, Short and wide...

    Next, imagine yourself placing something inside the box: a rock, a million dollars, your younger sibling...

    Wouldn't it be convenient if we could walk up to the box and just ask it to tell us what's inside instead of opening it ourselves? Actually, we can!

    <?php
    $mybox 
    = new Box("Jack");
    echo 
    $mybox-&gt;get_whats_inside();
    ?>

    Here the variable $mybox represents our self-aware box (also known as an object) which will be built by new--the world's smallest engineering and construction team. We also want to place Jack inside the box when it is built. When we want to ask the box it's contents, we'll apply a special get_whats_inside function to $mybox.

    The code won't run quite yet, though. We haven't supplied new with the directions for him and his team to construct our box and PHP doesn't know what the function get_whats_inside is supposed to do.

    More Programming Basics Articles
    More By bluephoenix

    blog comments powered by Disqus

    PROGRAMMING BASICS ARTICLES

    - Control Flow Constructs
    - More Time Manipulation with PHP
    - Validating and Manipulating Dates with PHP
    - Using the Date Constructor in PHP
    - Calendar Construction with PHP
    - PHP`s Calendar Package
    - Getting Modified Versions and Correct Dates ...
    - Combining Date Functions in PHP
    - Using PHP for Date and Time in Programming
    - More Exception Handling with PHP
    - Exception Handling in PHP
    - Error Logging and Handling Exceptions
    - Configuration Directives for Error and Excep...
    - Error and Exception Handling
    - Python Modules for Games


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