Avatar of Crazy Horse
Crazy Horse
Flag 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.
PHP

Avatar of undefined
Last Comment
Crazy Horse

8/22/2022 - Mon
Marco Gasi

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
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
Marco Gasi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Crazy Horse

ASKER
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!
Your help has saved me hundreds of hours of internet surfing.
fblack61