News for hackers. Stuff that matters.
Re:PHP Tips and Tricks - Codular by nodesocket on Sunday July 29, 2012 @07:30PM (#4310147)
`spl_autoload_register()` is awesome. This is how we implement it:

    spl_autoload_register(function ($class_name) {
        require(dirname(dirname(__FILE__)) . "/classes/" . $class_name . ".php");
    });
Protip here is `dirname(__FILE__)`
Re:PHP Tips and Tricks - Codular by jasonlotito on Sunday July 29, 2012 @08:38PM (#4310359)
See __DIR__ if >= 5.3
Re:PHP Tips and Tricks - Codular by ChiperSoft on Sunday July 29, 2012 @08:50PM (#4310381)
Which, since he's using an anonymous function, he would be.
Re:PHP Tips and Tricks - Codular by nodesocket on Sunday July 29, 2012 @09:03PM (#4310406)
Indeed, slightly cleaner I suppose:

    spl_autoload_register(function($class_name) {
        require(dirname(__DIR__) . "/classes/" . $class_name . ".php");
    });