PHP include file


Home - Tutorials - Basics

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
Level:Beginner
Product:See complete product

Bookmark PHP include file



spacer

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:

The final page is constructed by using all of the above mentioned files. The benfit of this structure is that if you need to change meta information you only need to edit the header.php file and so you probably make less error.

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:
In the next steps I will explain how to use them.





Next Step of PHP include file


Tags: php incluude file, php include, include file, file include, php, include, file

<Back - Tutorial Index Next - Step 2> -->
PHP include file - Table of contents
Step 1 - Include files introduction
Step 2 - The php include function
Step 3 - Include file more than once
Step 4 - The php require function
Step 5 - Include files only once


F1 Site Family
AJAX F1
CSS F1
Database F1
Flash F1
HTML F1
Java F1
JavaScript F1
PhotoShop F1
PHP F1
Scripts F1
Tutorial F1
Windows F1
 
spacer

Family tutorials
AJAX PHP
AJAX File Upload
AJAX Rating System
MySQL Create User
Mysqldump Example
MySQL Concat
JavaScript String
JavaScript Timeout
JavaScript Tooltip

Total time: 0.0149

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.