Inkludera filer i PHP
Låt oss säga att vi har en fil:
index.php<?php
echo 'index';
?>
Låt oss säga att det också finns en andra fil:
test.php<?php
echo 'test';
?>
Låt oss inkludera innehållet från den andra
filen i den första. Detta görs med kommandot
include:
index.php<?php
include 'test.php';
echo 'index';
?>
Samma fil kan inkluderas hur många gånger som helst:
index.php<?php
include 'test.php';
include 'test.php';
include 'test.php';
echo 'index';
?>
Задание 1
Skapa filerna file1.php, file2.php,
file3.php. Inkludera dem i din
huvudfil.