O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The include and require Functions

The include and require functions take the path to a file. The file is parsed as if it were a stand-alone PHP script. This is similar to the include directive in C and the require directive in Perl. There is a subtle difference between the two functions. When the require function is processed, it is replaced with the file it points to. The include function acts more like a function call.

The difference is most dramatic inside a loop. Imagine having three files you wanted to execute one after the other. You could put an include inside a for loop, and if the files were named something like include1.php, include2.php, and include3.php, you would have no problem. You could just build the name based on a counter variable. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required