Link to home
Start Free TrialLog in
Avatar of Crazy Horse
Crazy HorseFlag for South Africa

asked on

Is there a limit to how many lines of code your functions.php file can have?

I don't know how many lines is a little and how many is a lot but how many lines are acceptable in a functions.php file? I am not sure if this is a "how long is a piece of string?" question, but I am just trying to find out if I can keep going on and on forever or not.
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

AFAIK there is no such a limit... A php script can be as large as needed. I have never seen a script with millions of lines but this doesn't mean it can't exist. For sure I have seen many php scripts with thousands of lines.
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Crazy Horse

ASKER

In my effort to separate my concerns I create a lot of functions in the functions.php file and then just call whichever one I need.

So, if I have a registration page, at the bottom of my form I will just have something like:

<?php user_register($link); ?>

That user_register($link) function will have the form validation and insert record php code in it. And so it goes. I have done all of my code like that so when you look at the code for register.php, you don't have a whole lot of php tangled up with html, just that one line calling the function. As my project is growing, I am creating a lot of functions.

 I was starting to get concerned that it is getting too big, but the problem is that if I create specific function files for certain "modules" for lack of a better word, I am going to run into problems because some functions are dependent on others.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
All great answers, thanks. I was staring to think that I should have some sort of shared functions file for the functions that would be common across all areas of the site and then separate function files for the different secants of my site but wanted to just check with everyone. I have started refactoring my code in this way and it is so much easier to find code now. What a pleasure!