PHP output buffering? What's the best practise?

后端 未结 3 993
北荒
北荒 2021-01-19 18:17

Further to my previous question, what\'s the best approach when I want to buffer PHP output until I have performed all processing? I want to buffer to leave myself the optio

3条回答
  •  萌比男神i
    2021-01-19 18:40

    Well written code needs no output buffering. By that I mean: first, you do all your processing, without any output. Business logic, validation, database access - this kind of stuff. After this is done, you can close the DB connection, the session, etc. because all you do is create your output based on data collected above.
    This method usually results in far better maintainable code.

提交回复
热议问题