when i use include(),when require() in PHP script?

  • Thread starter Thread starter Saka
  • Start date Start date
S

Saka

Guest
please in practically is there any difference between include() and require().

please explain me
 
Unlike include(), require() will always read in the target file, even if the line it's on never executes. If you want to conditionally include a file, use include(). The conditional statement won't affect the require(). However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed.
 
They are virtually identical. The only difference between them is the way they handle failures. require() results in a both a warning and a fatal error upon failure, whereas include() only produces a warning.

Basically, require() will stop the script as soon as it fails, but include() will allow it to continue (even though it probably won't continue correctly without the code that was supposed to be included).
 
Back
Top