In this tutorial you will learn about the PHP File Inclusion and its application with practical example.
In PHP, you can call the content of one PHP Script into another PHP Script using PHP File Inclusion Mechanism.The include and require statements are used to insert script written in other files.
include and require are same in functionality, but:
- require will produce a fatal error and stop the script.
- include will only produce a warning and the script will continue.
The include() Function
1 2 |
include ("filename.php"); include_once ("filename.php");//File will be included only once |
The require() Function
1 2 |
require ("filename.php"); require_once ("filename.php");//File will be included only once |