Posts Tagged "classes"

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.

Read More