Skip to content

Instantly share code, notes, and snippets.

@johanbrook
Last active February 15, 2016 16:19
Show Gist options
  • Select an option

  • Save johanbrook/f4810c43412205adffed to your computer and use it in GitHub Desktop.

Select an option

Save johanbrook/f4810c43412205adffed to your computer and use it in GitHub Desktop.

Revisions

  1. johanbrook revised this gist Feb 15, 2016. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions index.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,14 @@
    <?php
    $page = $_GET['page'];
    $file = 'home.php';

    switch($page) {
    case 'about': $file = 'about.php'; break;
    default: $file = 'home.php';
    $map = [
    'about' => 'about.php';
    ];

    $file = $map[$page];

    # Fallback
    if(!$file) {
    $file = 'home.php';
    }
    ?>
    <!doctype html>
  2. johanbrook created this gist Feb 15, 2016.
    30 changes: 30 additions & 0 deletions index.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?php
    $page = $_GET['page'];
    $file = 'home.php';

    switch($page) {
    case 'about': $file = 'about.php'; break;
    default: $file = 'home.php';
    }
    ?>
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Test</title>
    <link rel="stylesheet" href="style.css">
    </head>
    <body>
    <header>
    <h1>Header</h1>
    </header>

    <main>
    <?php include $file; ?>
    </main>

    <footer>
    <p>Footer</p>
    </footer>
    </body>
    </html>