Jump to content

Difference between include, require, and require_once


SCook

Recommended Posts

They all do the same thing except when the path is incorrect

 

include will: give error but carry on loading.

require will: give fatal error and stop loading.

 

The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. They both produce a Warning' date=' but 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. Be warned that parse error in included file doesn't cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does.[/quote']

 

Using _once will stop the file from being loaded multiple times, like in a loop etc,

 

But as Thorpe said, use the manual

 

~ Chocopi

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.