Created
May 18, 2019 18:38
-
-
Save alexrusin/c6e6b0bf95a9993c24e237c405f07ace to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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