View Full Version : difference between include and Reuqire_once
07-12-2005, 02:29 PM
Can anyone explain, that what is the difference between "Include" and "require_once"
07-12-2005, 02:35 PM
The difference is in the level of error that will be returned if the file cannot be included/required.
Like include() and require(), include_once() returns a warning and require_once() returns a fatal error.
07-12-2005, 04:00 PM
Also, I believe that with require_once, PHP will not require the same file twice (which will often lead to errors) eg, the code:
will cause errors, becuase the first require loads the functions, and then the second file trys to re-declare them. using require_once in place of require will stop this from happening.
Like Sayonara said, there are different levels of warning for include & include_once, and require & require_once
07-12-2005, 04:01 PM
As with the *_once section for the functions, the difference this creates is that it will not include code already presented to it. So if you have a value that you would like to allow overwriting by another variable within an include, use include instead of include_once.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.