PHP HOME
PHP Introduction
PHP SETUP
PHP Syntax
PHP Data Types
PHP Outputs
PHP Variable
PHP Constant
PHP Strings
PHP Operators
PHP if else if
PHP Switch
PHP while loop
PHP for loop
PHP Arrays
PHP Functions
PHP Sorting Array
PHP Form Handling
PHP Form Validation
PHP Form Required
PHP Form URL/EMAIL
PHP Form Submit
PHP Contact Form
PHP DATE & TIME
PHP INCLUDE
PHP FILE HANDLING
PHP FILE OPEN/READ
PHP FILE CREATE/WRITE
PHP FILE UPLOAD
PHP SESSION
PHP COOKIES
PHP FILTER
PHP ERROR HANDLING
PHP EXCEPTION
PHP Redirects
PHP with MySQL
PHP WITH MYSQL DB
MYSQL CONNECT
MYSQL CREATE DATABASE
SELECT DATABASE
MYSQL CREATE TABLE
MYSQL INSERT DATA
MYSQL SELECT DATA
MYSQL UPDATE DATA
MYSQL DELETE DATA
MYSQL ORDER
MYSQL LIMIT
MYSQL LAST ID
By using these PHP function you can include one PHP file content to another PHP file before the server executes the code. There is two PHP function by which you can include. Those function built in default by PHP.
How many function include in PHP?
These are two PHP function by which you can include.
include() function
require() function
By using these function you can divide a thousands line of code of PHP file into multiple PHP files in the minimum line of code.
By this, you can easily understand the code.
PHP include() function copy all lines of code from a specified file and paste it into the file that uses the include() function.
If there is any problem while loading the included page then include function generates a warning but code execution will continue.
Example of PHP include() function.
This is the header.php page
<a href="home.php">Home</a> -
<a href="learn_html.php">HTML Tutorial</a> -
<a href="learn_css.php">CSS Tutorial</a> -
<a href="learn_js.php">JavaScript Tutorial</a> -
<a href="learn_php.php">PHP Tutorial</a>
This is another page home.php where we include header.php page by using the include function
<!DOCTYPE html>
<html>
<body>
<?php include 'header.php';?>
<h1>The is home page</h1>
</body>
</html>
PHP require() function copy all lines of code from a specified file and paste it into the file that uses the require() function.
If there is any problem while loading the included page then require function generates fatal error and code execution will be stopped.
Example of PHP require function
This is the header.php page
<a href="home.php">Home</a> -
<a href="learn_html.php">HTML Tutorial</a> -
<a href="learn_css.php">CSS Tutorial</a> -
<a href="learn_js.php">JavaScript Tutorial</a> -
<a href="learn_php.php">PHP Tutorial</a>
This is the footer.php page
<a href="http://www.raajrani.com/tutorials/">Designed & Developed by SAF Tutorials</a> -
<a href="#">All Rights Reserved</a>
This is another page home.php, where we include header.php and footer.php page by using, require function
<!DOCTYPE html>
<html>
<body>
<?php include 'header.php';?>
<h1>The is home page</h1>
<?php include 'footer.php';?>
</body>
</html>