include and require let you split code across files and reuse it — perfect for config files, layouts, and shared functions.
include — includes file; shows warning if missing, script continuesrequire — includes file; fatal error if missing, script stopsinclude_once — includes once even if called multiple timesrequire_once — requires once even if called multiple times// config.php
define("DB_HOST", "localhost");
define("DB_NAME", "myapp");
// index.php
require_once "config.php";
echo DB_HOST; // localhost
// header.php
?><header><h1>My Site</h1></header><?php
// footer.php
?><footer>© 2024</footer><?php
// page.php
require "header.php";
echo "<main>Page content</main>";
require "footer.php";
$title = "About Us";
$body = "We build great software.";
include "template.php"; // $title and $body are available inside