How many lines of PHP code is too many for one file?

前端 未结 8 2296
日久生厌
日久生厌 2021-02-20 15:55

I\'m creating a PHP file that does 2 mysql database calls and the rest of the script is if statements for things like file_exists and other simple variables. I have about 2000

8条回答
  •  清歌不尽
    2021-02-20 16:13

    You may want to read a book like Clean Code by Bob Martin. Here are a few nuggets from that book:

    • A class should have one responsibility
    • A function should do one thing and do it well

    With PHP, if you aren't using the Class approach; you're going to run into duplication problems. Do yourself a favor and do some reading on the subject; it'll save you a lot more time in extending and maintenance.

提交回复
热议问题