Some OOP stuff about PHP

After a long time, I took some time off to understand OOP in PHP, a language that was very familiar to me. Doing it in PHP was more fun than doing it in C++ (which i've done more than a dozen dozen times) even though my current language of choice would be Ruby or Clojure :)

I learnt the following

  1. Late static bindings is "over-riding for static functions"
  2. Define and use __autoload() to autoload class defs.
  3. The final keyword in php isn't same as the final in java. (final in java is const in php)
  4. Const methods and props are refered to in the same class using the self:: and not $this-> (The later is for non-const props and methods).
  5. $this is not available to static props and methods. Static props cannot be used on objects but only on class.
  6. Interfaces can be extended
  7. Type Hinting is awesome. Allows forcing PHP to work like a strictly-typed language.

One thing that I've always liked about PHP is that the docs are awesome and it's more awesome coz of the user comments on every doc page.

Posted