Skip to content

Instantly share code, notes, and snippets.

@voldern
Last active December 18, 2015 03:28
Show Gist options
  • Save voldern/5717948 to your computer and use it in GitHub Desktop.
Save voldern/5717948 to your computer and use it in GitHub Desktop.
<?php
session_start();
if (!empty($_REQUEST['dogs']) && is_array($_REQUEST['dogs'])) {
$dogs = $_REQUEST['dogs'];
} else {
$dogs = null;
header('HTTP/1.0 400 Bad Request', true, 400);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dogs > cats</title>
</head>
<body>
<?php if ($dogs !== null): ?>
<ul>
<?php foreach ($dogs as $index => $dog): ?>
<li>Dog <?php echo $index + 1 ?>: <?php echo htmlentities($dog) ?></li>
<?php endforeach ?>
</ul>
<?php else: ?>
<strong>Who let the dogs out?</strong>
<?php endif ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment