Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do you think i should keep all my php functions in one file?

i was wondering do you think i should keep all my functions in one file, or seperate them in different files!!

p.s if i put all the functions in one file, would it be easier for php to process that stuff!!

like image 865
getaway Avatar asked Nov 29 '22 05:11

getaway


2 Answers

It depends on how many functions they are, how long they are, and what they do. For any significant project, putting everything in one file is generally a bad idea. They should be categorized by what they do.

Having things in separate files is important not only for organization and legibility, but it also really helps during source control to see that a certain file has changed but all the others have stayed the same.

like image 154
Reinderien Avatar answered Dec 10 '22 21:12

Reinderien


According to my experience, the fewer files you include the faster a PHP script runs. If separating the functions in several files means you need to use include or require several times, it's probably best to keep the functions in one file.

like image 35
matsolof Avatar answered Dec 10 '22 19:12

matsolof