Skip to Content
Our misssion: to make the life easier for the researcher of free ebooks.

Including Files in PHP ? Beginner Tutorial

First, I want to say this is a beginner tutorial on including files with PHP. However, even if you are an intermediate or slightly beyond user, this tutorial may benefit you in some way because we are going to discuss some security features.

The main purpose of this tutorial is to kick off the new "Beginner" series of PHP tutorials. These tutorials will cover many of the common problems and questions, or misconceptions that we have seen on our forums and throughout the net regarding PHP. This tutorial will be fairly short, so even if you've been working with PHP for a while, you may still want to read on.

In addition, this tutorial is not written to read or write to other files. It is simply written to show new users how to include files properly.

The constructs we will discuss in this tutorial should be used when you want to pull together pieces of code or settings for your project. A common scenario would be a group of functions that you use throughout a website, or a class, or even a group of configuration settings, stored in a file such as a config.php with your site's pertinent information.

I would like to point out the fact that we are referring to constructs in this tutorial. Many people still consider these particular constructs as functions, however that is incorrect and we are going to refer to them the proper way, which is indeed a construct.

Including Files in PHP ? Beginner Tutorial