I’m developing a web application and I’m using a file called functions.php in which I stored all the functions related to my application, currently the file has about 1500 lines of code with over 30 functions.
I was wondering if it is a problem, could it slow down the process when calling functions? Should I make other files to move some of the functions there?
In most cases, the number of lines in the .php script isn’t going to affect the speed of the program nearly as much as the code itself. If execution time is your number one concern, then optimizing your code should be your number one priority. Start with the functions that are called the most, and make sure the code there is as tight as possible.
Splitting the functions up into different files would technically make the script slower since the interpreter would have to do disk I/O to parse the files. But the speed hit would be infinitesimal, so I’d argue that splitting them up might save time in the long run since it’ll be easier to debug and optimize if you’re not always staring down a huge file with 30 functions in it.
Finally, if you do have to use a bunch of huge .php files in your app, you might want to look into using something like Zend that will compile your scripts on the server.