PHP Interview Questions
What is difference between include(),require(),include_once() and require_once()?
Include() : Include is used to include files more than once in single PHP script.You can include a file as many times you want.
 
Syntax :
include(“file_name.php”);​
Include Once() : Include once include a file only one time in php script.Second attempt to include is ignored.
 
Syntax :
include_once(“file_name.php”);​
Require() : Require is also used to include files more than once in single PHP script.Require generates a Fatal error and halts the script execution,if file is not found on specified location or path.You can require a file as many time you want in a single script.
 
Syntax :
require(“file_name.php”);​
Require Once() : Require once include a file only one time in php script.Second attempt to include is ignored. Require Once also generates a Fatal error and halts the script execution ,if file is not found on specified location or path.
 
Syntax :
require_once(“file_name.php”);​