Multiple function in one file

3

I have a project in php and within this project, I have a folder named Funções . Inside this folder I have several function files.

I have a file named Logado.php , where I authenticate the user and call the pages to be loaded into it.

In every file I have on the site, I have to call the function file. I do it this way:

include "Funcoes/Inverte_Data.php";

What I wanted to know is, if I put all my functions inside a single file and call it in Logado.php , would it slow the system down?

I think it would be much more practical because, since all the functions are in the main file, I'll just be able to execute, like this:

inverteData($data);

What do you recommend I do?

    
asked by anonymous 28.07.2016 / 00:11

1 answer

3

It is interesting to have several functions in a file as long as they deal with the same "subject".

For example, you have functions for manipulating date, brParaSql , SqlParaBr , etc), so you can create a file with the class DateUtil and put these methods there, but this class can not contain methods that are unrelated to date (eg reverseTypeMultiples ) because it escapes class liability. These methods may be statistical, as they are methods that help and it is unnecessary to instantiate an object.

As for having to do multiple files, I see no problem, because if it were one, nobody would use framewoks because they have many files. And to solve the problem of having to write a lot of require, take a look at the PSR-0 which is about autoload.

    
28.07.2016 / 02:55