Visit the Official PHP Website

Search this Site

PHP Programming

By James N Hitz

Code Re-use... cont'd

There is still another way of including an external file into your page. This time we use require().

require() works exactly like include(). The only differences are:

  1. require cannot be conditionally parsed - all requires in a document will be parsed - whether they are included within an if statement block, a loop or otherwise
  2. a file CANNOT be parsed more than once if you use require() but will be parsed every time if called using include()

Other than that, a require() works just like an include().

<< Introduction to Code Re-use | Harvest Some More >>

JamHitz Productions