0

In php.net, we know the only different between "require" and "include" is how PHP reacts when the file begin included isn't available.

But some articles show that it includes and evaluate file every time while using "include". And "require" includes and evaluate file only once.

Is that means "require" is more efficient than "include"? If so, is that apply to each PHP version?

zcmyworld
  • 393
  • 1
  • 2
  • 9
  • 1
    the problem is not about performance but about possible errors when including same file 2 times, and about halting if there is a problem with inclusion – Flash Thunder Feb 12 '19 at 16:55
  • 1
    It's like the difference between single and double quotes. Hardly measurable, and not worth pondering prior database optimizations or actual code profiling. – mario Feb 12 '19 at 16:56
  • See [Difference between require, include, require_once and include_once?](https://stackoverflow.com/questions/2418473/difference-between-require-include-require-once-and-include-once?rq=1) – Adder Feb 12 '19 at 16:59
  • don't worry about performance of include and require - that's optimising at the completely wrong place. rather make sure your file structure is well-organized and your autoloaders are efficient, if you write them yourself. – Franz Gleichmann Feb 12 '19 at 17:01
  • `require` is more efficient than `include`. It stops your faulty script before it does another fool thing. – axiac Feb 12 '19 at 17:07
  • 1
    Actually I don't care about performance. I wonder what's the difference in the underlying implementation? – zcmyworld Feb 13 '19 at 04:38

0 Answers0