PHP include file - Include files only once
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.
|Name:||PHP include file|
Bookmark PHP include file
Step 5 - Include files only once
PHP include file
In a big and complaex project it can happen that you don't know whether a file was included yet or not. For example suppose the following situation:
- A.php includes B.php
- B.php includes C.php only if a condition is true in B.php
These functions first checks whether a file was included or not. After this check they include the file only if it was not included before. To demonstarte this let's go back to an older example and now use include_once instead of include as follows:
Output:-->internal.php<-- Multiple include test. Now include it again. Multiple include test.
Previous Step of PHP include file
Tags: php incluude file, php include, include file, file include, php, include, file