PHP include file
In this tutorial I will show you how to divide your code into more files and how to include various files into your actual PHP code.
Tutorial info:
| Name: | PHP include file |
| Total steps: | 5 |
| Category: | Basics |
| Date: | 2007-07-05 |
| Product: | See complete product |
Bookmark PHP include file
Step 1 - Include files introduction
PHP include file
If you want to make a project then it is not a good idea to put all of the code into one file. Even a quite simple task can result a huge amount of code. To maintain and reuse a code from a single file is quite hard.
If you download and check the source code of any PHP project you will find a lot of files. Each file contains only a well defined task implementation. For example in OOP each class has it's own file or you create a file for DB management an other one for mail sending and an other to display menu system.
A real example could be a project with the following files:
- index.php
- header.php
- footer.php
- menu.php
- content.php
However to make this sollution to work you need to learn how to include a file in an other one. There are more ways to do this in PHP. You can use the following functions:
- include
- require
- include_once
- require_once
Next Step of PHP include file
Tags: php incluude file, php include, include file, file include, php, include, file
