What’s the different between include and require?

shophia

New member
Joined
Mar 25, 2013
Messages
45
Points
0
Both are PHP syntax and used for including the files in the php files, however the difference is,

If the file is not found by require() syntax, it will reason a fatal error and end the execution of the script.
If the file is not found by include() syntax, a warning will be mattered, however execution will never end .
 

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,844
Points
0
Basically, the two functions are implemented include and require the same: PHP will load the entire contents of the file include or require, no matter what the format. For content in php tags will be executed as normal php file. For content outside of php tags will be printed.

Different between include and require in PHP:
include("file.php"): if the file does not exist file.php it will automatically execute the script again.

require ("file.php"): if the file does not exist, it will stand always file.php and execute any script that does the following. Therefore require the file is the most important file.

include_one like include, however include_once include only one single time.

require_once requires only 1 time for loading and it will not call for next loadings.
 

seoguy

New member
Joined
Aug 6, 2013
Messages
13
Points
0
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.
 

furious

New member
Joined
Nov 10, 2013
Messages
16
Points
0
oh php sounds so difficult but once you understand it is a very easy and strong language to start with
 
Newer threads
Latest threads
Replies
1
Views
80
Replies
1
Views
175
Replies
4
Views
383
Replies
11
Views
525
Replies
2
Views
228
Recommended threads
Replies
4
Views
3,973
Replies
1
Views
1,714
Replies
7
Views
2,210

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top