In order to reduce repeated code, it is often necessary to include header and footer. The most commonly used operations are require or require_once and other codes, but we can use another way to achieve this inclusion, write a function, For example, printHeader, as shown below, seems to be more troublesome to turn one line of code into two lines, but it can achieve some additional effects. For example, if we want each page to have a different title, we can pass parameters to this function (as shown below) Show).
function printHeader($title) { require("../lib/header.php"); }
Also in header.php
<html> <head> <title><?= $title ?></title> ...