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
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.