Inclusions

Inclusion is the operation to add PHP code stored in an external file, into another PHP code.

Inclusions rely on four native functions: include, require, include_once, require_once.

Inclusions have application with templates, configurations, caches, function libraries.

Inclusions have been superseded by autoload in recent PHP versions. Autoload relies on inclusion, though.

<?php

echo "A $color $fruit"; // A

include 'vars.php';

echo "A $color $fruit"; // A green apple

?>

Documentation

See also PHP Include & Require : All about Include vs Require in PHP

Related : Class Autoloading

Added in PHP 8.0+