On Mon, Nov 22, 2010 at 12:37 PM, Jason Pruim <lists@xxxxxxxxxxxxxxxxxxxx>wrote: > The autoloader function that is in PHP 5+ works on classes... But I'm not > finding anything that would do the same thing on the procedural end. > I'll start by explaining how it typically works with classes. The Zend Framework is a popular web/application class library. It organizes its classes into packages much like Java, Python, and other languages, where each package is a folder that contains other packages and classes. In Java, packages are a language feature so you have java.util.List which is the fully-qualified name of the List class that lives in the java.util package. PHP doesn't have the notion of packages, though 5.3 introduced namespaces which are similar but different. The autoloader function in PHP takes a class name and locates the file that should define it. In Zend this is done by separating the folder names by underscores, e.g. Zend_Http_Request. The autoloader splits the class name on underscores and looks in registered folders for a folder named Zend, and inside that for another folder named Http, and inside that for a file named Request.php. Zend's autoloader class provides more features such as aliases for folders so "ZF" would map to "Zend". The above is based on the convention of having one class per file. I doubt you'll be doing that for functions, so even if PHP had an autoloading mechanism for functions, you'd still need a way to map from function name to file name. I suppose you could do the same as above but drop the final name element when looking for the file. For example, the function math_trig_cos() would map to the function cos() defined in "math/trig.php". But it's all academic because PHP does not support such a feature. You could probably create a PHP extension if you wanna roll up your sleeves and get dirty in C. :) David