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

Including External Files in PHP

By Angela Bradley, About.com

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.

1 of 3

Index: Including External Files in PHP

  1. Include and Require
  2. Pulling The File
  3. More SSI

Explore PHP / MySQL

More from About.com

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

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

All rights reserved.