Thuta Learning
AdvancedProgrammingbeginner

Include & Require

Relax. We'll talk through this in plain words — no textbook voice.

include and require let you reuse repeated pieces of a file across your project. Splitting things like headers, footers, database connections, and helper functions into their own files makes the code much easier to maintain as your project grows.

php
<!-- index.php -->
<?php include "partials/header.php"; ?>

<h1>Welcome to my website</h1>
<p>This page uses a reusable header and footer.</p>

<?php include "partials/footer.php"; ?>
You should see
A page will render with a reusable header, content, and footer.

Easy traps

  • Never use user input directly as an include path — it can open up a file inclusion vulnerability.
Include & Require | Thuta Learning