Page 1 of 1

difference between include and require

Posted: Mon Aug 09, 2004 12:18 am
by bugthefixer
what is the difference between include and require

Posted: Mon Aug 09, 2004 1:12 am
by System_Failure
Its all over the net, all you gotta do is search with google ;)

http://www.google.com/search?q=differen ... equire+php
Qouted from the php manual:

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.

In PHP 3, it is possible to execute a return statement inside a require()ed file, as long as that statement occurs in the global scope of the require()ed file. It may not occur within any block (meaning inside braces ({}). In PHP 4, however, this ability has been discontinued. If you need this functionality, see include().