['09:00', '17:30'], 'Tuesday' => ['09:00', '17:30'], 'Wednesday' => ['09:00', '13:00'], 'Thursday' => ['09:00', '20:00'], 'Friday' => ['09:00', '17:30'], 'Saturday' => ['10:00', '16:00'], 'Sunday' => null, ]; // 4. A function with type declarations. htmlspecialchars() escapes <, >, & // and quotes, so text from visitors can't inject HTML or scripts (XSS). function h(string $text): string { return htmlspecialchars($text, ENT_QUOTES | ENT_HTML5, 'UTF-8'); } // 5. Input from the address bar (?name=Ada). ?? supplies a default when the // key is missing, as it always is on the command line. $name = trim((string) ($_GET['name'] ?? '')); $greeting = $name === '' ? 'Welcome' : "Welcome, {$name}"; // 6. Dates: name the time zone rather than relying on the server's setting. $now = new DateTimeImmutable('now', new DateTimeZone('Europe/Amsterdam')); $today = $now->format('l'); // 7. The closing tag: PHP stops here and the HTML below goes out as is. ?>
= h($title) ?> for the week. Today is = h($today) ?>.
| = h($day) ?> | = $slot === null ? 'Closed' : h("{$slot[0]} to {$slot[1]}") ?> |
|---|
Generated by PHP = h(PHP_VERSION) ?> at = h($now->format('H:i')) ?> (Amsterdam time).