The actual source

A little PHP

Read the whole file. This is the code the example uses, not a separately maintained copy.

pages/examples/greeting.phpOpen the example
<?php
use function Cornerstone\escape;

$name = is_string($_GET['name'] ?? null) ? trim($_GET['name']) : '';
$title = 'A little PHP goes a long way.';
require __DIR__ . '/../../partials/example-header.php';
?>

<h1>Hello, <?= escape($name !== '' ? $name : 'friend') ?>.</h1>
<p>A query string, a variable, and a little HTML.</p>

<form method="get" action="<?= escape($site->url('/examples/greeting')) ?>">
    <label for="name">Your name</label>
    <input id="name" name="name" value="<?= escape($name) ?>" maxlength="80">
    <button type="submit">Say hello</button>
</form>

<?php require __DIR__ . '/../../partials/example-footer.php'; ?>

Back to all examples