Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2013
    Location
    localhost
    Posts
    63
    Tokens
    412
    Habbo
    AaidenX

    Latest Awards:

    Default [TUT] OOP Programming [TUT]

    First off, you must be thinking what OOP means,

    O - Object
    O - Oriented
    P - PHP

    So I think you got a rough idea, what it means.

    Let's start with a bit of code!

    PHP Code:
    <?php

    ?>
    Those are the opening and closing codes.

    PHP Code:
    <?php

    class Test //You may use anything instead of test.
    {
    // Methods and properties are entered here for this class!
    }
    ?>
    That is a basic structure of a class. We'll go ahead dumbing the variables.

    PHP Code:
    <?php
    class Test
    {

    }
    $obj = new Test;
    var_dump($obj);
    So if you execute this, you'll get this display.

    PHP Code:
    object(Test)#1 (0) { } 
    PHP Code:
    <?php

    class Test {

    }
    $obj = new Test;

    ?>
    So in that, we remove the line, var_dump($obj); to stop dumping the variable, we'll be using the echo function to do so.

    PHP Code:
    <?php
    class Test {
          public 
    $prop1 "I can be anything you like!"
    }
    $obj = new Test;
    So the above codes add that $prop1 variable which is public and now we'll be showing it in OOP method.

    PHP Code:
    <?php
    class Test {
        public 
    $prop1 "I can be anything you like!"
    }
    $obj = new Test;
    echo 
    $obj->prop1
    So, if you execute it, your display would be:
    PHP Code:
    I can be anything you like
    Give me a like/rep if you find this useful! I'll return like/rep as well!

  2. #2
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by AaidenX View Post
    First off, you must be thinking what OOP means,

    O - Object
    O - Oriented
    P - PHP
    OOP stands for object-oriented programming.
    This is a horrible tutorial that doesn't teach anything or even explain why OOP is useful.

  3. #3
    Join Date
    Oct 2006
    Posts
    9,905
    Tokens
    26,858
    Habbo
    Zak

    Latest Awards:

    Default

    Quote Originally Posted by Trinity View Post
    OOP stands for object-oriented programming.
    This is a horrible tutorial that doesn't teach anything or even explain why OOP is useful.
    He is right lol

    Java would probably be the best language to demonstrate OOP. I thought a good tutorial on OOP would start with what it means and why 'object-orientation' is important in the first place. Starting with how to start and end PHP tags.. then demonstrating a class and executing doesn't really tell you anything about OOP?

  4. #4
    Join Date
    Jan 2013
    Location
    localhost
    Posts
    63
    Tokens
    412
    Habbo
    AaidenX

    Latest Awards:

    Default

    @Trinity bro, thats what I learnt... and I shared this.. c'mon!

  5. #5

    Default

    Quote Originally Posted by Zak View Post
    He is right lol
    Java would probably be the best language to demonstrate OOP. I thought a good tutorial on OOP would start with what it means and why 'object-orientation' is important in the first place. Starting with how to start and end PHP tags.. then demonstrating a class and executing doesn't really tell you anything about OOP?
    I agree with you. You gave more useful steps than topic starter did.
    Last edited by Nick; 24-09-2013 at 11:05 PM.

Posting Permissions

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