• Basic object oriented programming

      0 comments

    In a general php technical interview, they will ask basic OOP questions like follows, where a high skilled programmer also might get confused sometimes, if he does not know the basics.

    class a{
    function a(){
    echo ‘aaaa’;
    }
    }

    class b extends a{
    function b(){
    echo ‘bbbb’;
    parent::a();
    }
    }
    new b;

    The basic idea what we have to identify in this code snippet is,  whether the function names work as constructors or not?
    Yes, first it will call the function b and then it will call the function a. Which will out put,
    bbbbaaaa

    Related posts:

    1. Object Orientation with PHP5
    2. Abstract class and interface?

    Write a comment