PHP introduced a feature called autoloading. It allows you to specify a function that automatically loads classes when needed on the fly. This is to:
- prevent long lists of includes at the top of every script
- allow for cyclic dependencies
To further simplify stuff, I've developed a class loader utility class. You only include one file, tell the class where to find your classes (multiple directories supported!) and you're done.
Code and examples here:
http://www.bartvanhe...php/Classloader
The class loader
Started by Bart, Oct 07 2008 04:11 PM
2 replies to this topic
#2
Posted 07 October 2008 - 04:34 PM
Not bad. I wanted to write a class with some more functionality (e.g. multiple directories) than the usual __autoload() for some time, I just never really needed it.
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#3
Posted 08 October 2008 - 06:19 PM
on the site is a new version which:
- uses spl classes for searching the directory
- supports caching, which greatly improves speed
- uses spl classes for searching the directory
- supports caching, which greatly improves speed
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users