Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

include

Inclusion, often represented by the include keyword, is the process to read an external file, and evaluate with the current application for execution. It may define new structures, and execute code.

Inclusion relies on four language structures: include, require, include_once, require_once.

Inclusion is often hidden in autoload() functions: the code is included class per class, upon request.

vars.php
<?php

$color = 'green';
$fruit = 'apple';

?>

test.php
<?php

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

include 'vars.php';

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

?>

Documentation

See Also