PHP - Split code into multiple files or save as few files as possible?

Now I have a script that has reached 400 Kbytes in 4 files (about 3500 lines per file).

Should I split it into more files?

Does more files have a performance impact due to multiple calls require_once?

+3
source share
6 answers

I have a large 13,000 lines of script that I combined from the other three, but it fully scans and manages users, dealing with the conclusions and input techniques. The functions are in another file with 8000 lines, and I make sure there is zero bleeding between them. There is no HTML file in the function file, no SQL file in the main file. Would it be otherwise if I could use objects? Of course. I can not.

So, the moral of this story: it all depends on what is convenient for the script. I have another file with five small files, because it matters more; it makes sense as two big ones.

+1
source

require include PHP , ( ).

, , . , , .

+6

. , .. , require_once, , .

, : " ?". , , .

+2

, . profitphp , . ? , ?

, , ! , , . .

+2

I would seriously look at using an MVC framework like Kohana

+1
source

Split related strings into functions. Group functions and data in classes. If you do not think about how you organize your code when writing, you will create more work for someone else or yourself in the future.

+1
source

Source: https://habr.com/ru/post/1788239/


All Articles