/    Sign up×
Community /Pin to ProfileBookmark

using another file to store functions.

ok, I have a question. I have a php file that stores all my functions and I include() it into the pages that I use the functions on. I have about 1000 lines of code in the function file. My question is, does it matter if I have 1000 lines of php functions that I don’t use compared to 0 or just a small amount of lines of code? Basically, is it better to have only the needed functions written into the pages that need them or have a file with all the functions and include all the lines of code every time the functions file is used but not necessarily use all of the code?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleDec 02.2007 — Are all functions related? You should separate them into logical classes and only import what is needed.
Copy linkTweet thisAlerts:
@ss1289authorDec 07.2007 — Are all functions related? You should separate them into logical classes and only import what is needed.[/QUOTE]
Well what I want to know is if it matters how many lines of code you include into each page compared to how many you actually use. I'm looking to increase performance as best as possible.

So, say I have 1000 lines of code and I use about 950 lines. Is that faster than say if I had like 2000 lines of code and I only use 950 lines? Does it matter how big the file size is compared to the lines of code you use. Because a lot of my classes include other classes that I only use certain functions on. Most of my class files are included in other class files to the point that a majority of my class files are included in almost every page. But I don't always use the entire class in each file.
Copy linkTweet thisAlerts:
@jasonahouleDec 07.2007 — You don't want to be including code that won't be used. Also, it is good practice to have a single class per file. This makes it easier to maintain and allows you to include only what is needed.

There is a performance hit for having all that unused code. In a low traffic site it may not be noticeable but as traffic increases you may begin to see long load times.
×

Success!

Help @ss1289 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...