Include it is a part of control structure in PHP.
Include is used to evaluate or get specific file from the given path.
e.g:
include 'forloop.php' or include('forloop.php')
In the above example forloop.php is included in the current file.
IMP : If the given path or file is not available . The include will show warning as an output .
Warning will not affect other code which is going to be executed after include statement
e.g
Warning: include(forloop.php) [function.include]:
failed to open stream:
————————————————————————————————-
require it is a part of control structure in PHP.
Require is used to evaluate or get specific file from the given path.
e.g:
require 'forloop.php' or require ('forloop.php')
In the above example forloop.php is included in the current file.
IMP : If the given path or file is not available . The require will show fatal error as an output .
Fatal error will stop entire file execution . mean after this line none of the line will get executed
e.g
Fatal error: require(forloop.php) [function.require]:
failed to open stream:
Note : Its always better to use require instead of include to get proper result.
Leave a comment