+ Reply to Thread
Results 1 to 2 of 2

Thread: Introduction to OOP

  1. #1
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Introduction to OOP

    One of the most important aspects of programming is design. Although a poorly designed program may function fine at first, after a while when the website needs to be upgraded, the time it will take to make minor updates could have been used to rewrite the entire application. Abstraction and decoupling are the two idea's we have to keep in mind if we want to create a well designed application. Although it is not necessary, more times than not, an Object Oriented Application [OOP] has a better design that most other types of code. For this reason, it will introduce to you the basics of OOP.

    The first thing you need to do is create a class. The class header contains the key word class, followed by the name of the class, followed by an open brace. The footer contains the closing brace.

    Code:
    class HelloWorld {


    All the content of the class goes between the two braces. The next most important part of a class is the constructor. The constructor is the first method invoked when the class is instantiated. In PHP < 5 the constructor was declared as follows:

    Code:
    function HelloWorld() {


    And even in PHP 5.x that is acceptable, however PHP 5 has adopted a new convention, and since php 4.x is no longer supported, all my code will be PHP 5 oriented. The proper contention for PHP 5 is as follows:

    Code:
    function __construct() {


    That is , two underscores followed by the word construct. Now you can simply add your PHP code you wanted executed at run time in the constructor.

    Code:
    function __construct() {
        echo 
    "Hello World";

    The final class might look like this:
    Code:
    class HelloWorld {
        function 
    __construct() {
            echo 
    "Hello World";
        }


  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    fanaticweb is offline Newbie
    Join Date
    Jul 2008
    Posts
    1
    Rep Power
    0

    Re: Introduction to OOP

    brief of Exception, the exception is most important part of OOP concept, cause with exception, your software will be flexible, and easy to manipulate when the unwanted/wanted action such error, etc

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Introduction
    By mtbc123 in forum Introductions
    Replies: 1
    Last Post: 04-22-2011, 07:35 AM
  2. Hello everyone: My introduction
    By avr in forum Introductions
    Replies: 5
    Last Post: 01-28-2011, 02:48 AM
  3. Introduction
    By pidan in forum Introductions
    Replies: 8
    Last Post: 11-24-2009, 06:20 AM
  4. Introduction
    By onat12agi@gmail.com in forum Introductions
    Replies: 8
    Last Post: 10-14-2008, 05:41 AM
  5. Introduction
    By Rechocto in forum Introductions
    Replies: 6
    Last Post: 09-24-2008, 01:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts