difference between include and require

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

difference between include and require

Post by bugthefixer »

what is the difference between include and require
System_Failure
Forum Newbie
Posts: 18
Joined: Thu Aug 05, 2004 11:14 pm

Post 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().
Post Reply