Why use PHP OOP over basic functions and when?

后端 未结 10 1930
深忆病人
深忆病人 2020-12-04 13:14

There are some posts about this matter, but I didn\'t clearly get when to use object-oriented coding and when to use programmatic functions in an include. Somebody also ment

10条回答
  •  忘掉有多难
    2020-12-04 13:35

    I can't say which one is better. but in my experience you can have better code management using OOP. you know which code is where, what functionality is defined in which file, etc. about the runtime overhead for OOP I read somewhere (and I think it is true) that if you write a bad code in classic functions, and the same bad code in OOP, the function version works better. so if your code is not written bad, there is no proof that OOP is keeping your application slow. also remember that these "slow" and "overhead" stuff are all measured in milliseconds. so if your application is not serving a lot of users (like more than 100 users in a minute), you might not feel any difference.

提交回复
热议问题