A multi-function file OR multiple files with a function?

1

In the scope of my project I use include("funcoes.php") , inside this file has all the functions that I use in different parts of the project, I do not use all the functions at all time.

Then a question!

Pro system would be more advantageous, with respect to performance, use only this include and leave all functions there, or make multiple files, where each has its function determined, and according to the need to use the function use include("nome.funcao.php") , or the gain would not be so advantageous, so it would be easier to keep a single file and centralize everything in one scope!

My question is the following. In this file I have about 30 functions, simple functions to the most complex ones, except that I do not use the 30 all the time, and the include("funcoes.php") file is included at the top of all the pages, so assuming I use 5 functions, the other 25 were loaded "atoa".

    
asked by anonymous 10.05.2017 / 06:27

2 answers

1

In this amount of functions, this is irrelevant .

You will hardly find one file per function on old systems that used this structure that is now considered unproductive, unless you are doing something very simple or an embedded system.

We should privilege modern writing, taking advantage of the object orientation that has become robust in recent years and using the autoload of objects in Namespaces , which will load only what is called.

    
10.05.2017 / 13:50
1


Creating a file for each function is only relevant if they are very long functions, if they are relatively short functions the difference will be minimal and perhaps imperceptible. Home So if you prefer to do everything in one file do it if you prefer in several do in several.

    
10.05.2017 / 12:07