So to overcome this problem, file inclusion is used.
Methods to include the file
There are normally four methods to include file in php. These methods are used to include the content of file in your program before server execute it.
- include();
- include_once();
- require();
- require_once();
Example:-
include('myfile.php');
include_once('myfile.php');
require('myfile.php');
require_once('myfile.php');
Normally people use include() or require() as these functions working is almost same, the only differ between these is error handling process. Incase of any error in your code the include() generates the warning but script execution never stopped but when we use require() then incase of any error in your code, it generates a fatal error and execution of the program is stopped.
0 comments:
Post a Comment