The include statement

The include statement:
Using include, you can tell PHP to fetch a particular file and load all its contents. It’s as if you pasted the included file into the current file at the insertion point.

Syntax_
<?php
include "library.php";
//you code goes here
?>

Using include_once:
Each time you issue the include directive, it includes the requested file again, even if you’ve already inserted it. For instance, suppose that library.php contains a lot of useful functions, so you include it in your file, but also include another library that includes library.php.

Including a PHP file only once

<?php
include_once "library.php";
//Your code goes here
?>

Using require and require_once:
A potential problem with include and include_once is that PHP will only attempt to include the requested file. Program execution continues even if the file is not found.

<?php
require_once "library.php";
//your code goes here
?>
Translate »