1. Home
  2. Computing & Technology
  3. PHP / MySQL

Including External Files in PHP

By , About.com Guide

1 of 3

Include and Require

PHP is capable of utilizing SSI to include an external file into the file being executed. Two commands that do this are INCLUDE () and REQUIRE (). The difference between them is that when placed within a false conditional statement, the INCLUDE is not pulled but the REQUIRE is pulled and ignored. This means that in a conditional statement it can be faster to use INCLUDE. These commands are phrased as such:

INCLUDE 'http://www.yoursite.com/path/to/file.php' ;

//or

REQUIRE 'http://www.yoursite.com/path/to/file.php' ;

Some of the most common uses for these commands include holding variables that are used across multiple files or holding headers and footers. If an entire site's layout is housed in external files called with SSI, any changes to site design need only be made to these files and the entire site will change accordingly.

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. PHP Include - Include File in PHP - PHP Include File

©2009 About.com, a part of The New York Times Company.

All rights reserved.