Skip to content
AgileLogics
3 min read

Including Files

Prerequisites: Working with sessions & cookies

require/include pull another file's code into the current one — the basis for sharing code across pages before autoloading (Level 2) takes over for classes.

require 'header.php';   // fatal error if missing
include 'sidebar.php';   // warning only if missing, execution continues
require_once 'config.php'; // only includes it once, even if called again

Prefer require_once for configuration and function definitions — including them twice would redeclare a function and fatally error.