So far in my career as PHP programmer, I have stored my functions statically in class separated PHP files by topic (such as “database”, “htmlfunctions” etc). I recently had the idea of storing all my PHP functions in separate files and executing them by calling the include function in the appropriate spot, or including them on a need-to-use basis.
That would have the advantage of ridding me of the need to include a bunch of references and keeping track of which functions are in which files. In addition, I would be able to call functions from the address bar.
Parameters would be redundant since (from what I know) the include function copy/pastes file content directly and un-compiled into it’s place. The included files would then be able to use local and global variables.
What are your thoughts and comments on this, experts?
My thought is, that you might want to have a look into OOP and the PHP class autoloader features. Using global variables in your application without any level of encapsulation doesn’t sound like a good practice anymore.