1. Computing & Technology

Discuss in my forum

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.

©2012 About.com. All rights reserved.

A part of The New York Times Company.