<?php function lyn_copyright($startYear) { $currentYear = date('Y'); if ($startYear < $currentYear) { $currentYear = date('y'); return "© {$startYear}–{$currentYear}"; } else { return "© {$startYear}"; } } echo lyn_copyright(2030);
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Using server-side includes</title> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <h1>Including External Files</h1> <p>This paragraph is in the original file.</p> <?php include './includes/para.html'; ?> <p>This is also in the original file.</p> <?php include './includes/para.html'; require './includes/copyright.php'; ?> <p> <?php echo lyn_copyright(2015); ?> Patrick Krebs</p> </body> </html>
<?php $siteroot = '/introducingphp/ch07/07_03'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Using server-side includes</title> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <h1>Including External Files</h1> <p>This paragraph is in the original file.</p> <!-- This links to the end version of para.html --> <?php include_once './includes/para_end.html'; ?> <p>This is also in the original file.</p> <?php include_once './includes/para_end.html'; require './includes/copyright.php'; ?> <p><?php echo lyn_copyright(2016); ?> Tim Klein</p> </body> </html>