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
pixelwraith
Forum Newbie
Posts: 18
Joined: Wed Apr 14, 2004 11:01 am

difference between include and require

Post by pixelwraith »

is there any difference between include and require?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well.

When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward.
from the php manual
pixelwraith
Forum Newbie
Posts: 18
Joined: Wed Apr 14, 2004 11:01 am

Post by pixelwraith »

thanks! :D
Post Reply