Autoloading 101

For some who are new to PHP 5 you may have heard about a PHP feature called SPL Autoload or Autoloading classes.

Ordinarily, when you write a class your code may look something like this:

<?php

require_once('../code/foo.php');
require_once('../code/baz.php');

class widget extends foo
{
    public function event()
    {
        $baz = new baz();
    }
}

Autoloading does away with the need to put require / include once to include class file by enabling you to attach a function that performs an action before a class is instantiated. SPL autoload works when you try to instantiate a class or use reflection on a class and only works when the class hasn’t already been loaded.

Continue reading

On Resolutions

I’ve always been of the opinion that people put too much stock into New Year resolutions – simply because they eventually fall by the wayside. My only resolution has always been that the new year be better than the one just gone.

When I was deciding whether to restart my blog, I considered if it would be a good idea to import the 2000 or so posts I accumulated in archive form from personal sites going back to 2003. Every year up until 2007, I’d do a post about what I want to achieve in the new year but then I realised the process was pointless: being the best you can be was more important. I also decided not to import the posts simply because they’re rubbish.

This year, I thought it’d be fun to write down some resolutions and see how they pan out.

Continue reading