Skip to content

Instantly share code, notes, and snippets.

@alexrusin
Created May 18, 2019 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexrusin/c6e6b0bf95a9993c24e237c405f07ace to your computer and use it in GitHub Desktop.
Save alexrusin/c6e6b0bf95a9993c24e237c405f07ace to your computer and use it in GitHub Desktop.
<?php
if (!isset($_SERVER['REQUEST_URI']) || strtok($_SERVER["REQUEST_URI"],'?') !== '/greetings') {
http_response_code(404);
die();
}
$name = $_GET['name'] ?? 'Anonymous';
$greeting = $_GET['greeting'] ?? 'How do you do';
header('Content-Type: application/json');
http_response_code(200);
echo json_encode([
'greeting' => "$greeting, $name"
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment