PHP – Things I learned

  1. __construct only gets called when you instantiate an instance of a class and does not get fired when you call a static class function
    1. I would have thought that calling the static function would first fire __construct to setup anything applicable to that class and then call the static function.
    2. I don’t see many sensible reasons to use static class functions, unless you just don’t know where else to stuff the function. See – When to use Static Modifier and Static vs. Instaniated
    3. Static Methods used to be more popular before Namespaces were available in PHP. You’d create your own namespace by wrapping a bunch of static methods inside of a class
  2. empty() is an alias for !isset($var) || $var == false