Your Ad Here

Saturday, November 7, 2009

What are the differences between require and include,include_once,require_once?

require_once() and include_once() are both the functions to include and evaluate the specified file only once.
If the file is not present, require(), calls a fatal error, while in include() does not.

1 comment:

  1. Quoted 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().

    ReplyDelete

Your Ad Here