Do unused use statements decrease performance?

后端 未结 2 657
攒了一身酷
攒了一身酷 2021-01-04 05:19

I want to know if unused use statements in my class affect performance of my php website?

Does php include all classes in beginning or when need it?

2条回答
  •  渐次进展
    2021-01-04 05:48

    Newer versions of PHP, PHP 7 and especially PHP 7.2, is very good at optimising code when it's complied into byte code. I'm pretty sure unsed use statements are just stripped away by the compiler and will not even execute. Therefor it should not have any impact whatsoever. The compiler might use a few more CPU cycles but if you use OPCache there will be no effect on performance.

提交回复
热议问题