Posts Tagged ‘classes’

31 Mar

PHP __autoload() “not found” thowing exceptions

There is much debate about the __autoload function introduced in PHP5. I personally love it as all those requires, includes etc. made programs quite messy, and frankly annoy me if you create loads of pages that keep on requiring the same classes.

The one fault __autoload has though is that Exceptions cannot be thrown, and that to me would give potential for some great degradeablity.

Thankfully, there are a few ways of hacking the autoload function so that it does throw an Exception. The most common way is to create a class with the class name the autoload function is looking for using the eval() function, and then throw an exception once autoload is happy. (more…)

09 Jul

Binding just got easier

When coding in mootools, a lot of function binding goes on in my case. In fact, pretty much every time I call a class method I want it bound to the class. Jan Kassens comes to the rescue with a simple method which enables your class functions to be bound upon initialization. If you find yourself using .bind(this) a lot, this could make your code much prettier. (more…)