• Late static binding php5

      0 comments

    class A {
        public function who() {
            echo __CLASS__;
        }
        public function test() {
            $this->who();
        }
    }
    
    class B extends A {
        public function who() {
            echo __CLASS__;
        }
    }
    $obj = new B;
    $obj->test();
    

    Out put of the above snippet is? B This is mainly because we have the object instance named as $this is for the class B, though the function is instantiated inside class A. But, If you need the expected output which is “A”, we can call them statically as follows

    class A {
        public static function who() {
            echo __CLASS__;
        }
        public static function test() {
            self::who();
        }
    }
    
    class B extends A {
        public static function who() {
            echo __CLASS__;
        }
    }
    
    B::test();
    

    Out put -> A

    Main limitation of self:: or __CLASS__ are resolved using the class in which the function belongs, as in where it was defined. By introducing late static binding this limitation has been resolved as follows,

    class A {
        public static function who() {
            echo __CLASS__;
        }
        public static function test() {
            static::who(); // Here comes Late Static Bindings
        }
    }
    
    class B extends A {
        public static function who() {
            echo __CLASS__;
        }
    }
    
    B::test();
    

    Out put -> B

  • back to the basics

      0 comments

    This is just a quick note about how you must prepare for your technical interview whether it’s a face to face or a written.
    Before you prepare for a technical interview you must re-work on your basics in the first place. if you are not sure enough don’t go to the interview. Prepare well for your next interview. It will help you a lot  :)

    For an instance at least work on following aspects,

    • Client Server  – > What is client server architecture? Basic requesting methods to the server?
    • Sessions  -> What is a session? Where sessions are stored? How session reference is carried in the browser(client) side?
    • OOP     -> What is a class? what is overloading? what is overriding and how you do these with examples?
    • XML    -> What is xml? and what’s the use of it?
    • AJAX -> What is ajax? if you use 3rd party tool at least know the basic functions.
    • Frameworks – > Design patterns used? MVC? Explain cakephp, zend etc
    • CMS-> At least the knowledge of integrating a template. Joomla, Drupal, Magento