What is include() function in PHP?

The include statement takes all the code of another file and adds it to the current file, at the place where you write it. It is used to reuse parts like a header, a menu or a footer.

<?php
include "header.php";

echo "<p>Page content</p>";

include "footer.php";
?>

If the file is missing, include gives a warning, but the script continues. Related statements are include_once, require and require_once. See include() vs require() and PHP File Inclusion.


Learn more about the similar topics:
Tutorials
PHP Advanced
PHP File Upload
PHP File Handling
PHP File Inclusion
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What is include() function in PHP?
Can we include a file two times in any PHP page?
Which is the PHP function to delete a file from server?
What is fopen function PHP?
What is the difference between unlink() and unset() in PHP?
How to check if a file exists in PHP?
How to get the size of a file in PHP?