PHP allows to use one PHP or HTML file into other PHP files, it has following advantages

  1. Code reusability
  2. Easy error finding and debugging
  3. Large project can be managed easily.
  4. No code repetition or duplicacy.

To re-use files, PHP provides two functions.

  1. include
  2. require

include

It includes a given PHP or HTML file into another PHP file. If file is not found, it continues execution of PHP script with E_WARNING.

Syntax

include 'filename.php'; 

or 

include('filename.php');

Example

<?php
include('math.php');
?>

require

It works same as include but it stops execution if file is not found with fatal error E_COMPILE_ERROR

Syntax

require 'filename.php'; 
 or 
require('filename.php');

Example

<?php
 require('math.php');
?>