Skip to content

Instantly share code, notes, and snippets.

@bshaffer
Last active April 21, 2020 08:38
Show Gist options
  • Save bshaffer/d752d8c437f26dd0735fcff91ba9d7dc to your computer and use it in GitHub Desktop.
Save bshaffer/d752d8c437f26dd0735fcff91ba9d7dc to your computer and use it in GitHub Desktop.
Example PHP CGI-style front controller
<?php
// Static list provides security against URL injection by default.
switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
case '/':
require 'homepage.php';
break;
case 'admin.php':
require 'admin.php';
break;
default:
http_response_code(404);
exit('Not Found');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment