Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Oops and its features

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 137
    Comment on it

    Hello Readers

    Oops was introduced in php version 4 but the area of php version 4 is not very fast, as version 4 consists few features, hence the major concept of Oops are introduced in php version 5 which is called php5.

    Oops include the below things:

    1. Classes and objects

    2. Magic functions

    3. Specifiers(private, public and protected)

    4. Static method and property

    5. Abstract classes and interface

    6. Overloading and overriding

    7. Cloning

    8. Type hinting

    It is a technique to design the application and application could be any type like it could be web based application or any other application.

    In oops everything is around the classes and objects.

    Advantages of Oops:

    1. Open source

    2. stable

    3. re-usability of code

    4. easy to maintain

    5. Good level of abstraction

    6. clear structure of code

    7. much suitable for large projects

    8. memory management features

    9. Late binding

    Basic example of oops using class and its object in php

    <?php
     
    class oopsClass
    {
      // Class properties and methods go here
    }
     
    ?>
    

    After creating the class, a new class can be instantiated and stored in a variable using the new keyword:

    $obj = new oopsClass;
    

    To see the contents of the class, use var_dump():

    var_dump($obj);
    

    Now we merge all the above code and save in php file name called demo.php

    <?php
     
    class oopsClass
    {
        // Class properties and methods go here
    }
     
    $obj = new oopsClass;
     
    var_dump($obj);
     
    ?>
    

    Load the page in your browser at http://localhost/demo.php and the following should display:

    object(oopsClass)#1 (0) { }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: