php – Multiple functions in one file


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

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

On every file I have on the website, 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 called it in Logado.php , would it slow down the system?

Because 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 it, like this:


What do you recommend me to do?


It's nice to have multiple functions in a file as long as they deal with the same "subject".

For example, you have functions to manipulate date ( invert , brToSql , SqlToBr , etc), so you can create a file with the DateUtil class and put these methods there, but this class cannot contain methods that are unrelated to date (eg. reverseLetrasMaiusculas ) because it is not the responsibility of the class. These methods can be statistical, as they are methods that serve to help and it is unnecessary to have to instantiate an object.

As for having to include several files, I don't see a problem, because if it were one, no one 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 PSR-0 which deals with autoload.

Scroll to Top