elibraryportal Logo

Include and Require Files in PHP


PHP allows you to include file so that a page content can be reused many times. There are two ways to include file in PHP.

  1. include
  2. require

1) Include File in PHP

Include File is used to include on the basis of given path or source.

Syntax

PHP include Examples:

menu.html

includeexample.php

Output

 ROJGAR BHARAT |   
 JANO_JAGO |   
 eLIBRARY PORTAL |
 This is include example

2) PHP require File

PHP require is just like include.

PHP requir Examples:

menu.html

requirExample.php

Output

 ROJGAR BHARAT |   
 JANO_JAGO |   
 eLIBRARY PORTAL |  This is requir example

Next Topic